From d3bb91522f4ea936318596662b86cd872884d365 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
(cherry picked from commit 715301cef5835b14c37267055e13a6b02d66ab1a)
(cherry picked from commit 46a51b42983ff07d8e49b0365e108a8ed85d7004)
---
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 b839ef79c7386..62e3633f6b29d 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/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;