We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5155

Summary: [Patch] HIDAPI_JoystickDisconnected incorrect array shift
Product: SDL Reporter: Anthony Pesch <inolen>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: scale memmove size by sizeof(SDL_JoystickID)

Description Anthony Pesch 2020-05-23 16:52:19 UTC
Created attachment 4355 [details]
scale memmove size by sizeof(SDL_JoystickID)

Hi Sam,

I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward.

The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
Comment 1 Sam Lantinga 2020-05-30 04:22:32 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/44fbeca0872e