From 5f936a6276490c1e82d8de7a733f8148d4acf659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 Dec 2023 18:48:24 +0100 Subject: [PATCH] Fix glfwGetKeyName not checking key token is valid (cherry picked from commit b1517e5b3ee6f060f2e7ebd47c9de0c10e6ad411) --- src/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/input.c b/src/input.c index 047d75dc..0ae27eef 100644 --- a/src/input.c +++ b/src/input.c @@ -616,6 +616,12 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode) if (key != GLFW_KEY_UNKNOWN) { + if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) + { + _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key); + return NULL; + } + if (key != GLFW_KEY_KP_EQUAL && (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) && (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))