From 9a769da04ab2bd45f1632312e09258b5de7f6c91 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 7 Sep 2020 20:10:50 -0700 Subject: [PATCH] X11: Remove our X11 error callback in X11_DeleteDevice() If we don't remove it, we will infinitely recurse if X11_CreateDevice() is called again and orig_x11_errhandler becomes X11_SafetyNetErrHandler(). --- src/video/x11/SDL_x11video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 8ae4b6cb6..4ae9544e6 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -92,6 +92,8 @@ get_classname() /* X11 driver bootstrap functions */ +static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; + static void X11_DeleteDevice(SDL_VideoDevice * device) { @@ -100,6 +102,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) device->Vulkan_UnloadLibrary(device); } if (data->display) { + X11_XSetErrorHandler(orig_x11_errhandler); X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); @@ -111,7 +114,6 @@ X11_DeleteDevice(SDL_VideoDevice * device) /* An error handler to reset the vidmode and then call the default handler. */ static SDL_bool safety_net_triggered = SDL_FALSE; -static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL; static int X11_SafetyNetErrHandler(Display * d, XErrorEvent * e) {