From 18046b9aa3dabcc9bdc8d90c47c0721b25e032a1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 26 Sep 2022 20:53:50 -0700 Subject: [PATCH] Fixed crash with a NULL serial number --- src/joystick/hidapi/SDL_hidapijoystick.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index e3db2cfc5..3fe935ef3 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -534,6 +534,10 @@ HIDAPI_HasConnectedUSBDevice(const char *serial) { SDL_HIDAPI_Device *device; + if (!serial) { + return SDL_FALSE; + } + for (device = SDL_HIDAPI_devices; device; device = device->next) { if (!device->driver) { continue; @@ -555,6 +559,10 @@ HIDAPI_DisconnectBluetoothDevice(const char *serial) { SDL_HIDAPI_Device *device; + if (!serial) { + return; + } + for (device = SDL_HIDAPI_devices; device; device = device->next) { if (!device->driver) { continue;