Fixed read after free bug in the game controller.
authorSam Lantinga <slouken@libsdl.org>
Thu, 07 Mar 2013 15:17:06 -0800
changeset 6975 36145df5a4dc
parent 6974 11a03a79dfe8
child 6976 177d1dc3dba6
Fixed read after free bug in the game controller.
src/joystick/SDL_gamecontroller.c
--- a/src/joystick/SDL_gamecontroller.c	Wed Mar 06 11:59:21 2013 -0800
+++ b/src/joystick/SDL_gamecontroller.c	Thu Mar 07 15:17:06 2013 -0800
@@ -678,17 +678,18 @@
     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 );