From ec13c0f5dc64752bce2dd9f2fdf9188185c4b035 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Mon, 28 Nov 2022 22:28:35 +0900 Subject: [PATCH] Fix array out of range This breaks other values of the struct. --- src/rcore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 06f9bbdd6..5eda7650e 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3514,7 +3514,7 @@ int GetKeyPressed(void) CORE.Input.Keyboard.keyPressedQueue[i] = CORE.Input.Keyboard.keyPressedQueue[i + 1]; // Reset last character in the queue - CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 0; + CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1] = 0; CORE.Input.Keyboard.keyPressedQueueCount--; } @@ -3536,7 +3536,7 @@ int GetCharPressed(void) CORE.Input.Keyboard.charPressedQueue[i] = CORE.Input.Keyboard.charPressedQueue[i + 1]; // Reset last character in the queue - CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = 0; + CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount - 1] = 0; CORE.Input.Keyboard.charPressedQueueCount--; } @@ -5370,7 +5370,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key) // Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char // Check if there is space available in the queue - if (CORE.Input.Keyboard.charPressedQueueCount < MAX_KEY_PRESSED_QUEUE) + if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE) { // Add character to the queue CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = key;