Fixed crash if info->path is NULL

This commit is contained in:
Sam Lantinga
2025-03-17 09:46:27 -07:00
parent f5eea7efa2
commit 715301cef5

View File

@@ -871,10 +871,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
return NULL; return NULL;
} }
SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, true); SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, true);
device->path = SDL_strdup(info->path); if (info->path) {
if (!device->path) { device->path = SDL_strdup(info->path);
SDL_free(device);
return NULL;
} }
device->seen = true; device->seen = true;
device->vendor_id = info->vendor_id; device->vendor_id = info->vendor_id;