Skip to content

Commit

Permalink
Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen
Browse files Browse the repository at this point in the history
meyraud705

Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
  • Loading branch information
slouken committed Jun 3, 2020
1 parent 134362e commit eea0b0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/joystick/windows/SDL_rawinputjoystick.c
Expand Up @@ -592,8 +592,8 @@ RAWINPUT_JoystickOpen(SDL_Joystick * joystick, int device_index)
}

if (!device->driver->OpenJoystick(&device->hiddevice, joystick)) {
/* Only possible error is out of memory */
return SDL_OutOfMemory();
SDL_free(hwdata);
return -1;
}

hwdata->reserved = (void*)-1; /* crash if some code slips by that tries to use this */
Expand Down

0 comments on commit eea0b0e

Please sign in to comment.