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 4843

Summary: Passing NULL to memset in SDL_PrivateLoadButtonMapping
Product: SDL Reporter: Mathieu Eyraud <meyraud705>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: 2.0.10   
Hardware: All   
OS: All   
Attachments: Check naxes before memset

Description Mathieu Eyraud 2019-10-21 12:17:05 UTC
Created attachment 3994 [details]
Check naxes before memset

If gamecontroller does not have any axis then NULL is passed to memset in SDL_PrivateLoadButtonMapping (src/joystick/SDL_gamecontroller.c line 694).

In SDL_GameControllerOpen:
gamecontroller->last_match_axis is initialized to NULL on line 1572 by calloc;
Assuming gamecontroller has no axis on line 1586, gamecontroller->last_match_axis is still NULL;
Calling SDL_PrivateLoadButtonMapping on line 1608;
Calling memset on gamecontroller->last_match_axis on line 694.
Comment 1 Sylvain 2019-10-23 07:54:29 UTC
Thanks! Fixed in https://hg.libsdl.org/SDL/rev/e12b547e5856