mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
SDL_keyboard.c: Add bounds guards when assigning to the scancode array.
Based on a patch by Jochen Schäfer <josch1710@live.de> : On a T420 pressing the ACPI button for volume control, big scancodes were emitted. This was causing an overflow, because missing guards.
This commit is contained in:
parent
eb15b4e962
commit
d28437de3c
@ -605,6 +605,9 @@ SDL_SetKeymap(int start, SDL_Keycode * keys, int length)
|
|||||||
void
|
void
|
||||||
SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
|
SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
|
||||||
{
|
{
|
||||||
|
if (scancode >= SDL_NUM_SCANCODES) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SDL_scancode_names[scancode] = name;
|
SDL_scancode_names[scancode] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +678,7 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode)
|
|||||||
Uint32 type;
|
Uint32 type;
|
||||||
Uint8 repeat = SDL_FALSE;
|
Uint8 repeat = SDL_FALSE;
|
||||||
|
|
||||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
if (scancode == SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +803,7 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode)
|
|||||||
allowing the user to escape the application */
|
allowing the user to escape the application */
|
||||||
SDL_MinimizeWindow(keyboard->focus);
|
SDL_MinimizeWindow(keyboard->focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (posted);
|
return (posted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user