Commit 8b64a78da989e4efa45697a435b76828a820df0e

Sam Lantinga 2016-10-07T17:26:25

Fixed bug 2956 - De-reference videodata without NULL check in X11_DispatchEvent(_THIS) function

diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index e7dbd11..5d7f1df 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -536,7 +536,7 @@ static void
 X11_DispatchEvent(_THIS)
 {
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
-    Display *display = videodata->display;
+    Display *display;
     SDL_WindowData *data;
     XEvent xevent;
     int orig_event_type;
@@ -544,6 +544,11 @@ X11_DispatchEvent(_THIS)
     XClientMessageEvent m;
     int i;
 
+    if (!videodata) {
+        return;
+    }
+    display = videodata->display;
+
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
     X11_XNextEvent(display, &xevent);