Only free EventData if it's successfully retrieved.
authorEdward Rudd <urkle@outoforder.cc>
Thu, 23 May 2013 18:45:14 -0400
changeset 7214 5b31583ecf9e
parent 7213 53df899db00b
child 7215 41e739a52f69
Only free EventData if it's successfully retrieved. - straight from http://who-t.blogspot.com/2009/07/xi2-and-xlib-cookies.html - hopefully fixes random crash on some systems
src/video/x11/SDL_x11events.c
--- a/src/video/x11/SDL_x11events.c	Tue May 21 22:48:50 2013 -0700
+++ b/src/video/x11/SDL_x11events.c	Thu May 23 18:45:14 2013 -0400
@@ -187,10 +187,11 @@
 #if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
 static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event)
 {
-    XGenericEventCookie *cookie = &event.xcookie;
-    XGetEventData(videodata->display, cookie);
-    X11_HandleXinput2Event(videodata,cookie);
-    XFreeEventData(videodata->display,cookie);
+    if (XGetEventData(videodata->display, &event)) {
+        XGenericEventCookie *cookie = &event.xcookie;
+        X11_HandleXinput2Event(videodata, cookie);
+        XFreeEventData(videodata->display, cookie);
+    }
 }
 #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */