Skip to content

Commit

Permalink
Fixed crash if a device doesn't have a USB product or manufacturer st…
Browse files Browse the repository at this point in the history
…ring

This happens with the Razer Huntsman V3 Pro Tenkeyless keyboard
  • Loading branch information
slouken committed Dec 5, 2024
1 parent 9f8157f commit 235e5c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/joystick/hidapi/SDL_hidapijoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,10 @@ char *HIDAPI_GetDeviceProductName(Uint16 vendor_id, Uint16 product_id)
SDL_LockJoysticks();
for (device = SDL_HIDAPI_devices; device; device = device->next) {
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();
Expand All @@ -1309,7 +1312,10 @@ char *HIDAPI_GetDeviceManufacturerName(Uint16 vendor_id, Uint16 product_id)
SDL_LockJoysticks();
for (device = SDL_HIDAPI_devices; device; device = device->next) {
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();
Expand Down

0 comments on commit 235e5c6

Please sign in to comment.