diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-11-07 21:46:02 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-11-21 14:03:03 +0000 |
commit | 80bca45f2068fac1ce0647fcd1a00cddf5dd7f80 (patch) | |
tree | 718981ac6c7e9059a6b99aa70a4c5db37ca75b6c | |
parent | b3d30df1fd2684766bd8a0ba3a50b3329ad6521c (diff) |
Handle some crashes shown up by quick_window test
If the window is deleted very quickly after it is created, we might still be
in xcwm_window_create(), trying to obtain window information. Make sure that
we just return NULL if the window no longer exists...
-rw-r--r-- | src/libxcwm/image.c | 3 | ||||
-rw-r--r-- | src/libxcwm/window.c | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/libxcwm/image.c b/src/libxcwm/image.c index 8389720..eed868e 100644 --- a/src/libxcwm/image.c +++ b/src/libxcwm/image.c @@ -44,6 +44,9 @@ xcwm_image_copy_full(xcwm_window_t *window) geom_reply = _xcwm_get_window_geometry(window->context->conn, window->window_id); + if (!geom_reply) + return NULL; + xcb_flush(window->context->conn); /* Get the full image of the window */ image = xcb_image_get(window->context->conn, diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c index 68c725a..030a27a 100644 --- a/src/libxcwm/window.c +++ b/src/libxcwm/window.c @@ -99,6 +99,12 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window, _xcwm_get_window_attributes(context->conn, new_window); if ((!attrs) || (attrs->_class == XCB_WINDOW_CLASS_INPUT_ONLY)) return NULL; + + xcb_get_geometry_reply_t *geom; + geom = _xcwm_get_window_geometry(context->conn, new_window); + if (!geom) + return NULL; + /* allocate memory for new xcwm_window_t and rectangles */ xcwm_window_t *window = malloc(sizeof(xcwm_window_t)); assert(window); @@ -109,9 +115,6 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window, window->sizing = calloc(1, sizeof(*window->sizing)); assert(window->dmg_bounds);; - xcb_get_geometry_reply_t *geom; - geom = _xcwm_get_window_geometry(context->conn, new_window); - /* set any available values from xcb_create_notify_event_t object pointer and geom pointer */ window->context = context; |