diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 85bf9a067..c68ee8b8a 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -565,6 +565,10 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + if (!data) { + return; /* can happen when returning from fullscreen Space on shutdown */ + } + unsigned short scancode = [event keyCode]; SDL_Scancode code; #if 0 diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index a78fb2589..d231684a2 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -349,8 +349,11 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) } SDL_Mouse *mouse = SDL_GetMouse(); - SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; + if (!driverdata) { + return; /* can happen when returning from fullscreen Space on shutdown */ + } + const SDL_bool seenWarp = driverdata->seenWarp; driverdata->seenWarp = NO;