Only free EventData if it's successfully retrieved.
authorEdward Rudd <urkle@outoforder.cc>
Thu, 23 May 2013 18:45:14 -0400
changeset 72145b31583ecf9e
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
     1.1 --- a/src/video/x11/SDL_x11events.c	Tue May 21 22:48:50 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11events.c	Thu May 23 18:45:14 2013 -0400
     1.3 @@ -187,10 +187,11 @@
     1.4  #if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS
     1.5  static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event)
     1.6  {
     1.7 -    XGenericEventCookie *cookie = &event.xcookie;
     1.8 -    XGetEventData(videodata->display, cookie);
     1.9 -    X11_HandleXinput2Event(videodata,cookie);
    1.10 -    XFreeEventData(videodata->display,cookie);
    1.11 +    if (XGetEventData(videodata->display, &event)) {
    1.12 +        XGenericEventCookie *cookie = &event.xcookie;
    1.13 +        X11_HandleXinput2Event(videodata, cookie);
    1.14 +        XFreeEventData(videodata->display, cookie);
    1.15 +    }
    1.16  }
    1.17  #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
    1.18