From 715301cef5835b14c37267055e13a6b02d66ab1a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 17 Mar 2025 09:46:27 -0700
Subject: [PATCH] Fixed crash if info->path is NULL
---
src/joystick/hidapi/SDL_hidapijoystick.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 15699802f21df..8c9d8537861e3 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -871,10 +871,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
return NULL;
}
SDL_SetObjectValid(device, SDL_OBJECT_TYPE_HIDAPI_JOYSTICK, true);
- 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 = true;
device->vendor_id = info->vendor_id;