From 1dec4dd800157ac4ec9795c076b4bddd30463ad6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 7 Mar 2013 15:17:06 -0800 Subject: [PATCH] Fixed read after free bug in the game controller. --- src/joystick/SDL_gamecontroller.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index d312b854f..585e955cc 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -678,17 +678,18 @@ SDL_GameControllerAddMapping( const char *mappingString ) SDL_bool is_xinput_mapping = SDL_FALSE; #endif - pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString ); - if (!pchGUID) return -1; + pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString ); + if (!pchGUID) { + return -1; + } #ifdef SDL_JOYSTICK_DINPUT if ( !SDL_strcasecmp( pchGUID, "xinput" ) ) { is_xinput_mapping = SDL_TRUE; } #endif + jGUID = SDL_JoystickGetGUIDFromString(pchGUID); SDL_free(pchGUID); - jGUID = SDL_JoystickGetGUIDFromString(pchGUID); - pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID); pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString );