Mac: Fix a crash with SDL_MAC_NO_SANDBOX.
authorSam Lantinga <slouken@libsdl.org>
Fri, 08 Nov 2013 14:05:08 -0800
changeset 7917 686df9c2b98a
parent 7916 8f16728ce87b
child 7918 934f1630a86f
Mac: Fix a crash with SDL_MAC_NO_SANDBOX. When we get a kCGEventTapDisabledByTimeout or kCGEventTapDisabledByUserInput, the event tap would perform an invalid memory access. void pointers are so fun. This code only runs if you explicitly build with SDL_MAC_NO_SANDBOX.
src/video/cocoa/SDL_cocoamousetap.m
--- a/src/video/cocoa/SDL_cocoamousetap.m	Fri Nov 08 14:04:59 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamousetap.m	Fri Nov 08 14:05:08 2013 -0800
@@ -60,7 +60,7 @@
 static CGEventRef
 Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
 {
-    SDL_MouseData *driverdata = (SDL_MouseData*)refcon;
+    SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
     SDL_Mouse *mouse = SDL_GetMouse();
     SDL_Window *window = SDL_GetKeyboardFocus();
     NSRect windowRect;
@@ -71,7 +71,7 @@
         case kCGEventTapDisabledByTimeout:
         case kCGEventTapDisabledByUserInput:
             {
-                CGEventTapEnable(((SDL_MouseEventTapData*)(driverdata->tapdata))->tap, true);
+                CGEventTapEnable(tapdata->tap, true);
                 return NULL;
             }
         default: