mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
Fixed crash if joystick functions are passed a NULL joystick
This commit is contained in:
@@ -1521,6 +1521,9 @@ const char *SDL_GetJoystickName(SDL_Joystick *joystick)
|
||||
const SDL_SteamVirtualGamepadInfo *info;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, NULL);
|
||||
|
||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||
if (info) {
|
||||
retval = info->name;
|
||||
@@ -1529,6 +1532,7 @@ const char *SDL_GetJoystickName(SDL_Joystick *joystick)
|
||||
|
||||
retval = joystick->name;
|
||||
}
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
/* FIXME: Really we should reference count this name so it doesn't go away after unlock */
|
||||
@@ -3247,6 +3251,9 @@ Uint16 SDL_GetJoystickVendor(SDL_Joystick *joystick)
|
||||
const SDL_SteamVirtualGamepadInfo *info;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, 0);
|
||||
|
||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||
if (info) {
|
||||
vendor = info->vendor_id;
|
||||
@@ -3255,6 +3262,7 @@ Uint16 SDL_GetJoystickVendor(SDL_Joystick *joystick)
|
||||
|
||||
SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return vendor;
|
||||
@@ -3266,6 +3274,9 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
|
||||
const SDL_SteamVirtualGamepadInfo *info;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
CHECK_JOYSTICK_MAGIC(joystick, 0);
|
||||
|
||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||
if (info) {
|
||||
product = info->product_id;
|
||||
@@ -3274,6 +3285,7 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
|
||||
|
||||
SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL);
|
||||
}
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return product;
|
||||
|
Reference in New Issue
Block a user