qnx: fixed potential buffer overflow.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 01 Jul 2017 19:52:12 -0400
changeset 11120e1fc7d3b46fb
parent 11119 28d3a50e276e
child 11121 a544d3b5a993
qnx: fixed potential buffer overflow.
src/video/qnx/keyboard.c
     1.1 --- a/src/video/qnx/keyboard.c	Sat Jul 01 17:50:47 2017 -0400
     1.2 +++ b/src/video/qnx/keyboard.c	Sat Jul 01 19:52:12 2017 -0400
     1.3 @@ -30,7 +30,7 @@
     1.4   * A map thta translates Screen key names to SDL scan codes.
     1.5   * This map is incomplete, but should include most major keys.
     1.6   */
     1.7 -static int  key_to_sdl[] = {
     1.8 +static int key_to_sdl[] = {
     1.9      [KEYCODE_SPACE] = SDL_SCANCODE_SPACE,
    1.10      [KEYCODE_APOSTROPHE] = SDL_SCANCODE_APOSTROPHE,
    1.11      [KEYCODE_COMMA] = SDL_SCANCODE_COMMA,
    1.12 @@ -107,7 +107,7 @@
    1.13      }
    1.14  
    1.15      // Skip unrecognized keys.
    1.16 -    if ((val < 0) || (val > (sizeof(key_to_sdl) / sizeof(int)))) {
    1.17 +    if ((val < 0) || (val >= SDL_TABLESIZE(key_to_sdl))) {
    1.18          return;
    1.19      }
    1.20