Commit 774b07751314de950b5a635906979b7aa74c3b6f

Philipp Wiesemann 2015-09-21T21:19:37

iOS: Fixed pointer dereference after free.

diff --git a/src/joystick/iphoneos/SDL_sysjoystick.m b/src/joystick/iphoneos/SDL_sysjoystick.m
index ef63484..e9ad049 100644
--- a/src/joystick/iphoneos/SDL_sysjoystick.m
+++ b/src/joystick/iphoneos/SDL_sysjoystick.m
@@ -228,9 +228,6 @@ SDL_SYS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device)
     }
 #endif /* SDL_JOYSTICK_MFI */
 
-    SDL_free(device->name);
-    SDL_free(device);
-
     --numjoysticks;
 
 #if !SDL_EVENTS_DISABLED
@@ -245,6 +242,9 @@ SDL_SYS_RemoveJoystickDevice(SDL_JoystickDeviceItem *device)
     }
 #endif /* !SDL_EVENTS_DISABLED */
 
+    SDL_free(device->name);
+    SDL_free(device);
+
     return next;
 }