Fix lock up in GetKeyNameText due to an increment wrap when KeyCode is

a char type and max_keycode is 255.
This commit is contained in:
Dave Hawkes 2001-11-20 18:49:38 +00:00 committed by Alexandre Julliard
parent 9cef2d0b1d
commit e58557c634
1 changed files with 5 additions and 3 deletions

View File

@ -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",