Fix Bug 1533 - SDL_Keycode value range allows segfaults with negative values; add test coverage to keyboard suite
This commit is contained in:
parent
f41de44a36
commit
5916b2bc1e
2 changed files with 133 additions and 57 deletions
|
@ -861,7 +861,7 @@ SDL_GetKeyFromScancode(SDL_Scancode scancode)
|
|||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (scancode<SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
||||
if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
||||
SDL_InvalidParamError("scancode");
|
||||
return 0;
|
||||
}
|
||||
|
@ -887,8 +887,13 @@ SDL_GetScancodeFromKey(SDL_Keycode key)
|
|||
const char *
|
||||
SDL_GetScancodeName(SDL_Scancode scancode)
|
||||
{
|
||||
const char *name = SDL_scancode_names[scancode];
|
||||
const char *name;
|
||||
if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
|
||||
SDL_InvalidParamError("scancode");
|
||||
return "";
|
||||
}
|
||||
|
||||
name = SDL_scancode_names[scancode];
|
||||
if (name)
|
||||
return name;
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue