Fixed crash if joystick functions are passed a NULL joystick
parent
4ce935b910
commit
0dfdf1f3f2
|
@ -1521,6 +1521,9 @@ const char *SDL_GetJoystickName(SDL_Joystick *joystick)
|
||||||
const SDL_SteamVirtualGamepadInfo *info;
|
const SDL_SteamVirtualGamepadInfo *info;
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
|
{
|
||||||
|
CHECK_JOYSTICK_MAGIC(joystick, NULL);
|
||||||
|
|
||||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||||
if (info) {
|
if (info) {
|
||||||
retval = info->name;
|
retval = info->name;
|
||||||
|
@ -1529,6 +1532,7 @@ const char *SDL_GetJoystickName(SDL_Joystick *joystick)
|
||||||
|
|
||||||
retval = joystick->name;
|
retval = joystick->name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
||||||
/* FIXME: Really we should reference count this name so it doesn't go away after unlock */
|
/* 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;
|
const SDL_SteamVirtualGamepadInfo *info;
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
|
{
|
||||||
|
CHECK_JOYSTICK_MAGIC(joystick, 0);
|
||||||
|
|
||||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||||
if (info) {
|
if (info) {
|
||||||
vendor = info->vendor_id;
|
vendor = info->vendor_id;
|
||||||
|
@ -3255,6 +3262,7 @@ Uint16 SDL_GetJoystickVendor(SDL_Joystick *joystick)
|
||||||
|
|
||||||
SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL);
|
SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
||||||
return vendor;
|
return vendor;
|
||||||
|
@ -3266,6 +3274,9 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
|
||||||
const SDL_SteamVirtualGamepadInfo *info;
|
const SDL_SteamVirtualGamepadInfo *info;
|
||||||
|
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
|
{
|
||||||
|
CHECK_JOYSTICK_MAGIC(joystick, 0);
|
||||||
|
|
||||||
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id);
|
||||||
if (info) {
|
if (info) {
|
||||||
product = info->product_id;
|
product = info->product_id;
|
||||||
|
@ -3274,6 +3285,7 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
|
||||||
|
|
||||||
SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL);
|
SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
||||||
return product;
|
return product;
|
||||||
|
|
Loading…
Reference in New Issue