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 - Passing NULL to memset in SDL_PrivateLoadButtonMapping
Summary: Passing NULL to memset in SDL_PrivateLoadButtonMapping
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.10
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-21 12:17 UTC by Mathieu Eyraud
Modified: 2019-10-23 07:54 UTC (History)
1 user (show)

See Also:


Attachments
Check naxes before memset (699 bytes, patch)
2019-10-21 12:17 UTC, Mathieu Eyraud
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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