Mac: Fix a crash with SDL_MAC_NO_SANDBOX.
authorSam Lantinga <slouken@libsdl.org>
Fri, 08 Nov 2013 14:05:08 -0800
changeset 7917686df9c2b98a
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
     1.1 --- a/src/video/cocoa/SDL_cocoamousetap.m	Fri Nov 08 14:04:59 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamousetap.m	Fri Nov 08 14:05:08 2013 -0800
     1.3 @@ -60,7 +60,7 @@
     1.4  static CGEventRef
     1.5  Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
     1.6  {
     1.7 -    SDL_MouseData *driverdata = (SDL_MouseData*)refcon;
     1.8 +    SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
     1.9      SDL_Mouse *mouse = SDL_GetMouse();
    1.10      SDL_Window *window = SDL_GetKeyboardFocus();
    1.11      NSRect windowRect;
    1.12 @@ -71,7 +71,7 @@
    1.13          case kCGEventTapDisabledByTimeout:
    1.14          case kCGEventTapDisabledByUserInput:
    1.15              {
    1.16 -                CGEventTapEnable(((SDL_MouseEventTapData*)(driverdata->tapdata))->tap, true);
    1.17 +                CGEventTapEnable(tapdata->tap, true);
    1.18                  return NULL;
    1.19              }
    1.20          default: