From 00db2ee5ffd3934f2699e17f5ba793c86d87b27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 4 Jul 2013 02:29:32 -0400 Subject: [PATCH] xwayland: Don't crash when we get configure notify for destroyed frame windows We can get a destroy notify for the frame window after we've removed it from the hash table. This turns into a NULL pointer deref when we look up the window and try to use it for debugging printout. Fixes the failing xwayland test case. --- src/xwayland/window-manager.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c index e39ce0a5..b9891833 100644 --- a/src/xwayland/window-manager.c +++ b/src/xwayland/window-manager.c @@ -551,6 +551,16 @@ weston_wm_handle_configure_request(struct weston_wm *wm, xcb_generic_event_t *ev weston_wm_window_schedule_repaint(window); } +static int +our_resource(struct weston_wm *wm, uint32_t id) +{ + const xcb_setup_t *setup; + + setup = xcb_get_setup(wm->conn); + + return (id & ~setup->resource_id_mask) == setup->resource_id_base; +} + static void weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *event) { @@ -559,14 +569,15 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *eve struct weston_wm_window *window; int x, y; - window = hash_table_lookup(wm->window_hash, configure_notify->window); - - wm_log("XCB_CONFIGURE_NOTIFY (%s window %d) %d,%d @ %dx%d\n", - configure_notify->window == window->id ? "client" : "frame", + wm_log("XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d\n", configure_notify->window, configure_notify->x, configure_notify->y, configure_notify->width, configure_notify->height); + if (our_resource(wm, configure_notify->window)) + return; + + window = hash_table_lookup(wm->window_hash, configure_notify->window); /* resize falls here */ if (configure_notify->window != window->id) return; @@ -671,16 +682,6 @@ weston_wm_window_transform(struct wl_listener *listener, void *data) old_sy = sy; } -static int -our_resource(struct weston_wm *wm, uint32_t id) -{ - const xcb_setup_t *setup; - - setup = xcb_get_setup(wm->conn); - - return (id & ~setup->resource_id_mask) == setup->resource_id_base; -} - #define ICCCM_WITHDRAWN_STATE 0 #define ICCCM_NORMAL_STATE 1 #define ICCCM_ICONIC_STATE 3