From: RĂ©mi Denis-Courmont Date: Sun, 11 Apr 2010 16:52:34 +0000 (+0300) Subject: Safety checks for X11 error handlers X-Git-Tag: 1.1.0-pre1~32 X-Git-Url: https://git.sesse.net/?p=vlc;a=commitdiff_plain;h=209c152e39ae22bf3842ff81f5b829c099d3aae7 Safety checks for X11 error handlers --- diff --git a/bin/override.c b/bin/override.c index c6084d88e4..113a638445 100644 --- a/bin/override.c +++ b/bin/override.c @@ -192,6 +192,43 @@ int sigaction (int signum, const struct sigaction *act, struct sigaction *old) } +/*** Xlib ****/ +#ifdef HAVE_X11_XLIB_H +# include + +static pthread_mutex_t xlib_lock = PTHREAD_MUTEX_INITIALIZER; + +int (*XSetErrorHandler (int (*handler) (Display *, XErrorEvent *))) + (Display *, XErrorEvent *) +{ + if (override) + { + int (*ret) (Display *, XErrorEvent *); + + pthread_mutex_lock (&xlib_lock); + LOG("Error", "%p", handler); + ret = CALL(XSetErrorHandler, handler); + pthread_mutex_unlock (&xlib_lock); + return ret; + } + return CALL(XSetErrorHandler, handler); +} + +int (*XSetIOErrorHandler (int (*handler) (Display *))) (Display *) +{ + if (override) + { + int (*ret) (Display *); + + pthread_mutex_lock (&xlib_lock); + LOG("Error", "%p", handler); + ret = CALL(XSetIOErrorHandler, handler); + pthread_mutex_unlock (&xlib_lock); + return ret; + } + return CALL(XSetIOErrorHandler, handler); +} +#endif #else static void vlc_enable_override (void) {