mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-24 04:35:03 +00:00
Check for NULL before dereferencing newly allocated memory
Fixes https://github.com/libsdl-org/SDL/issues/8289 (cherry picked from commit 70a1bc69739016884a22abe6bf86f8a5deba29ef)
This commit is contained in:
parent
834e8898b9
commit
27f2df2292
|
@ -1752,11 +1752,11 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
|
||||||
/* We temporarily open the device to check how it's configured. Make
|
/* We temporarily open the device to check how it's configured. Make
|
||||||
a fake SDL_Joystick object to do so. */
|
a fake SDL_Joystick object to do so. */
|
||||||
joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
|
joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
|
||||||
joystick->magic = &SDL_joystick_magic;
|
|
||||||
if (joystick == NULL) {
|
if (joystick == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
joystick->magic = &SDL_joystick_magic;
|
||||||
SDL_memcpy(&joystick->guid, &item->guid, sizeof(item->guid));
|
SDL_memcpy(&joystick->guid, &item->guid, sizeof(item->guid));
|
||||||
|
|
||||||
joystick->hwdata = (struct joystick_hwdata *)
|
joystick->hwdata = (struct joystick_hwdata *)
|
||||||
|
|
Loading…
Reference in a new issue