浏览代码

Fixed crash if the controller product name is NULL

This happens when the Razer Synapse software emulates a controller with a keyboard
Sam Lantinga 1 年之前
父节点
当前提交
7117d545a3
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/joystick/SDL_joystick.c

+ 4 - 2
src/joystick/SDL_joystick.c

@@ -2581,7 +2581,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);
@@ -2597,7 +2597,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;
 }