Переглянути джерело

Fixed crash if info->path is NULL

(cherry picked from commit 715301cef5835b14c37267055e13a6b02d66ab1a)
(cherry picked from commit 46a51b42983ff07d8e49b0365e108a8ed85d7004)
Sam Lantinga 1 місяць тому
батько
коміт
d3bb91522f
1 змінених файлів з 2 додано та 4 видалено
  1. 2 4
      src/joystick/hidapi/SDL_hidapijoystick.c

+ 2 - 4
src/joystick/hidapi/SDL_hidapijoystick.c

@@ -890,10 +890,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
         return NULL;
     }
     device->magic = &SDL_HIDAPI_device_magic;
-    device->path = SDL_strdup(info->path);
-    if (!device->path) {
-        SDL_free(device);
-        return NULL;
+    if (info->path) {
+        device->path = SDL_strdup(info->path);
     }
     device->seen = SDL_TRUE;
     device->vendor_id = info->vendor_id;