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
This commit is contained in:
Edward Rudd 2013-05-23 18:45:14 -04:00
parent 9e842c74c1
commit 0ce4bb89d8

View file

@ -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 */