[rlgl] Fix matrix stack overflow in rlPushMatrix() (#5935)

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.

Co-authored-by: Brandon Arrendondo <brandon.arrendondo@bissell.com>
This commit is contained in:
Brandon Arrendondo
2026-06-24 10:38:08 -04:00
committed by GitHub
parent d1a14bee5d
commit 83cb4cc210

View File

@@ -1237,7 +1237,11 @@ void rlMatrixMode(int mode)
// Push the current matrix into RLGL.State.stack
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)
{