From 0f871c033c9f990250b62bd9c5d71441c1266c97 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Wed, 23 Oct 2019 09:53:23 +0200 Subject: [PATCH] Fixed bug 4843 - Passing NULL to memset in SDL_PrivateLoadButtonMapping (Thanks!) --- src/joystick/SDL_gamecontroller.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 488ccb570..a974bd48e 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -691,7 +691,9 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, con gamecontroller->name = pchName; gamecontroller->num_bindings = 0; - SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); + if (gamecontroller->joystick->naxes) { + SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); + } SDL_PrivateGameControllerParseControllerConfigString(gamecontroller, pchMapping);