Skip to content

Commit

Permalink
Fixed crash if the controller product name is NULL
Browse files Browse the repository at this point in the history
This happens when the Razer Synapse software emulates a controller with a keyboard

(cherry picked from commit 7117d54)
(cherry picked from commit 7f880c9)
  • Loading branch information
slouken committed Dec 18, 2024
1 parent 4568e64 commit ca8e333
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/joystick/SDL_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc
*guid16++ = SDL_SwapLE16(bus);
*guid16++ = SDL_SwapLE16(crc);

if (vendor && product) {
if (vendor) {
*guid16++ = SDL_SwapLE16(vendor);
*guid16++ = 0;
*guid16++ = SDL_SwapLE16(product);
Expand All @@ -2511,7 +2511,9 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc
guid.data[14] = driver_signature;
guid.data[15] = driver_data;
}
SDL_strlcpy((char *)guid16, product_name, available_space);
if (product_name) {
SDL_strlcpy((char *)guid16, product_name, available_space);
}
}
return guid;
}
Expand Down

0 comments on commit ca8e333

Please sign in to comment.