Skip to content

Commit 66a2cde

Browse files
authored
Fix array out of range (#2814)
This breaks other values of the struct.
1 parent bbf9935 commit 66a2cde

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rcore.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ int GetKeyPressed(void)
35163516
CORE.Input.Keyboard.keyPressedQueue[i] = CORE.Input.Keyboard.keyPressedQueue[i + 1];
35173517

35183518
// Reset last character in the queue
3519-
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 0;
3519+
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1] = 0;
35203520
CORE.Input.Keyboard.keyPressedQueueCount--;
35213521
}
35223522

@@ -3538,7 +3538,7 @@ int GetCharPressed(void)
35383538
CORE.Input.Keyboard.charPressedQueue[i] = CORE.Input.Keyboard.charPressedQueue[i + 1];
35393539

35403540
// Reset last character in the queue
3541-
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = 0;
3541+
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount - 1] = 0;
35423542
CORE.Input.Keyboard.charPressedQueueCount--;
35433543
}
35443544

@@ -5372,7 +5372,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
53725372
// Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char
53735373

53745374
// Check if there is space available in the queue
5375-
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
5375+
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
53765376
{
53775377
// Add character to the queue
53785378
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = key;

0 commit comments

Comments
 (0)