Commit 201484ff6fa5f6216696e6a77c029352b2b97e65

Sam Lantinga 2022-08-09T09:03:28

Don't duplicate the serial number twice if a child doesn't set one

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/joystick/hidapi/SDL_hidapi_combined.c b/src/joystick/hidapi/SDL_hidapi_combined.c
index 6ccbcbf..27da8dd 100644
--- a/src/joystick/hidapi/SDL_hidapi_combined.c
+++ b/src/joystick/hidapi/SDL_hidapi_combined.c
@@ -94,6 +94,8 @@ HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys
                 serial = new_serial;
                 serial_length = new_length;
             }
+            SDL_free(joystick->serial);
+            joystick->serial = NULL;
         }
     }