Fix undefined behaviour in X11 keypress handling

`1 << 31` is undefined because 1 is an int, so the shift would set the sign bit
This commit is contained in:
Silver 2021-11-11 10:06:24 +00:00
parent fb0f2f92a3
commit 920afdd1ce

View File

@ -1269,7 +1269,7 @@ static void processEvent(XEvent *event)
// (the server never sends a timestamp of zero)
// NOTE: Timestamp difference is compared to handle wrap-around
Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31)))
if (diff == event->xkey.time || (diff > 0 && diff < ((Time)1 << 31)))
{
if (keycode)
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods);