[rlgl] Fix matrix stack overflow in rlPushMatrix()

The RL_MAX_MATRIX_STACK_SIZE check logged an error but did not return, so
RLGL.State.stack[stackCounter] = *currentMatrix still executed when the stack
was full -- writing one element past stack[RL_MAX_MATRIX_STACK_SIZE] and
corrupting the adjacent RLGL.State members (stackCounter, etc.). rlPopMatrix()
already guards the symmetric underflow case; add the missing early return.
This commit is contained in:
Brandon Arrendondo 2026-06-23 20:19:42 -04:00
parent 962bbfc6bf
commit 5cfac55e34

View File

@ -1237,7 +1237,11 @@ void rlMatrixMode(int mode)
// Push the current matrix into RLGL.State.stack // Push the current matrix into RLGL.State.stack
void rlPushMatrix(void) void rlPushMatrix(void)
{ {
if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)"); if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE)
{
TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)");
return;
}
if (RLGL.State.currentMatrixMode == RL_MODELVIEW) if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
{ {