mirror of https://github.com/libsdl-org/SDL.git
Fixed crash if a device doesn't have a USB product or manufacturer string
This happens with the Razer Huntsman V3 Pro Tenkeyless keyboard
This commit is contained in:
parent
9f8157f42c
commit
235e5c6a6c
|
|
@ -1293,7 +1293,10 @@ char *HIDAPI_GetDeviceProductName(Uint16 vendor_id, Uint16 product_id)
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
||||||
if (vendor_id == device->vendor_id && product_id == device->product_id) {
|
if (vendor_id == device->vendor_id && product_id == device->product_id) {
|
||||||
name = SDL_strdup(device->product_string);
|
if (device->product_string) {
|
||||||
|
name = SDL_strdup(device->product_string);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
@ -1309,7 +1312,10 @@ char *HIDAPI_GetDeviceManufacturerName(Uint16 vendor_id, Uint16 product_id)
|
||||||
SDL_LockJoysticks();
|
SDL_LockJoysticks();
|
||||||
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
for (device = SDL_HIDAPI_devices; device; device = device->next) {
|
||||||
if (vendor_id == device->vendor_id && product_id == device->product_id) {
|
if (vendor_id == device->vendor_id && product_id == device->product_id) {
|
||||||
name = SDL_strdup(device->manufacturer_string);
|
if (device->manufacturer_string) {
|
||||||
|
name = SDL_strdup(device->manufacturer_string);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockJoysticks();
|
SDL_UnlockJoysticks();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue