| Summary: | Memory leak in SDL_xinputjoystick minimal example program | ||
|---|---|---|---|
| Product: | SDL | Reporter: | sdlbugs |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | ||
| Version: | 2.0.10 | ||
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
| Attachments: | Diff for fixing leak in SDL2-2.0.12 | ||
Note, you might need a controller plugged in to cause the leak |
Created attachment 4265 [details] Diff for fixing leak in SDL2-2.0.12 Several memory leaks noted in SDL_xinputjoystick.c when the following program run on a Windows machine: #include "SDL.h" int main() { SDL_SetMainReady(); SDL_Init(SDL_INIT_GAMECONTROLLER); SDL_Quit(); return 0; } I don't remember spotting these in 2.0.10, but they're there in 2.0.12. Reported as 2.0.10 though because 2.0.12 isn't an option at this time. Attached a patch that fixes them. Problems were: - GuessXInputDevice() does not delete dynamically allocated local member 'devices' on all return paths. - SDL_XINPUT_JoystickQuit() does not delete static device info, so name strings leak. I also added (redundant) array initialisation code to s_arrXInputDevicePath[] to make it extra, extra clear that it needs to be null'd before use.