mirror of https://github.com/mpv-player/mpv
x11: slightly safer X11 error handler behavior
The X11 error handler is global, and not per-display. If another Xlib user exists in the process, they can conflict. In theory, it might happen that e.g. another library sets an error handler (overwriting the mpv one), and some time after mpv closes its display, restores the error handler to mpv's one. To mitigate this, check if the error log instance is actually set, instead of possibly crashing. The change in vo_x11_uninit() is mostly cosmetic.
This commit is contained in:
parent
11406b9215
commit
8fe33a11e2
|
@ -280,6 +280,9 @@ static void vo_set_cursor_hidden(struct vo *vo, bool cursor_hidden)
|
|||
static int x11_errorhandler(Display *display, XErrorEvent *event)
|
||||
{
|
||||
struct mp_log *log = x11_error_output;
|
||||
if (!log)
|
||||
return 0;
|
||||
|
||||
char msg[60];
|
||||
XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
|
||||
|
||||
|
@ -746,8 +749,8 @@ void vo_x11_uninit(struct vo *vo)
|
|||
if (x11->xim)
|
||||
XCloseIM(x11->xim);
|
||||
if (x11->display) {
|
||||
x11_error_output = NULL;
|
||||
XSetErrorHandler(NULL);
|
||||
x11_error_output = NULL;
|
||||
XCloseDisplay(x11->display);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue