From 55375b9858d1d6dcf80426877b793ce8b8fccc60 Mon Sep 17 00:00:00 2001 From: MoD Date: Tue, 11 Jun 2013 19:59:42 -0500 Subject: [PATCH] xwm: Check result of xcb_get_atom_name_reply When printing debug information about atoms, the XWM would crash if the X server failed to respond to a request about atom names. In practice this occurred when the server itself crashed, e.g. when starting mplayer with the "xv" vo. --- src/xwayland/window-manager.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c index e656eda37..3fc56337a 100644 --- a/src/xwayland/window-manager.c +++ b/src/xwayland/window-manager.c @@ -137,9 +137,15 @@ get_atom_name(xcb_connection_t *c, xcb_atom_t atom) cookie = xcb_get_atom_name (c, atom); reply = xcb_get_atom_name_reply (c, cookie, &e); - snprintf(buffer, sizeof buffer, "%.*s", - xcb_get_atom_name_name_length (reply), - xcb_get_atom_name_name (reply)); + + if(reply) { + snprintf(buffer, sizeof buffer, "%.*s", + xcb_get_atom_name_name_length (reply), + xcb_get_atom_name_name (reply)); + } else { + snprintf(buffer, sizeof buffer, "(atom %u)", atom); + } + free(reply); return buffer;