Fix glfwGetKeyName not checking key token is valid

(cherry picked from commit b1517e5b3e)
This commit is contained in:
Camilla Löwy 2023-12-04 18:48:24 +01:00
parent 1c989eace3
commit 5f936a6276

View File

@ -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))