From 0ce4bb89d8c13695e95efac0b990bed75054b4a4 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Thu, 23 May 2013 18:45:14 -0400 Subject: [PATCH] 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 318c2947b..025777aee 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -187,10 +187,11 @@ static char* X11_URIToLocal(char* uri) { #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 */