From e58557c634af9f8f8f1907ca7071759eda1a2d8a Mon Sep 17 00:00:00 2001 From: Dave Hawkes Date: Tue, 20 Nov 2001 18:49:38 +0000 Subject: [PATCH] Fix lock up in GetKeyNameText due to an increment wrap when KeyCode is a char type and max_keycode is 255. --- windows/x11drv/keyboard.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/windows/x11drv/keyboard.c b/windows/x11drv/keyboard.c index 0ff17cb2ade..ec7ed25861b 100644 --- a/windows/x11drv/keyboard.c +++ b/windows/x11drv/keyboard.c @@ -1311,6 +1311,7 @@ INT X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT nSize) { int vkey, ansi, scanCode; KeyCode keyc; + int keyi; KeySym keys; char *name; @@ -1374,11 +1375,12 @@ INT X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT nSize) /* let's do scancode -> keycode -> keysym -> String */ - for (keyc=min_keycode; keyc<=max_keycode; keyc++) - if ((keyc2scan[keyc]) == scanCode) + for (keyi=min_keycode; keyi<=max_keycode; keyi++) + if ((keyc2scan[keyi]) == scanCode) break; - if (keyc <= max_keycode) + if (keyi <= max_keycode) { + keyc = (KeyCode) keyi; keys = TSXKeycodeToKeysym(thread_display(), keyc, 0); name = TSXKeysymToString(keys); TRACE("found scan=%04x keyc=%04x keysym=%04x string=%s\n",