x11: Check for XCB reply

Now that mutter can survive Xwayland vanishing in mid-flight, we need to
actually check if the Xserver reply fetched though XCB is not NULL,
otherwise we may crash, that would be a shame.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1638
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1718>
This commit is contained in:
Olivier Fourdan 2021-02-08 18:19:01 +01:00 committed by Marge Bot
parent 9b8cff8673
commit 445373d028
2 changed files with 6 additions and 10 deletions

View File

@ -56,12 +56,12 @@ meta_group_new (MetaX11Display *x11_display,
group->refcount = 1; /* owned by caller, hash table has only weak ref */
xcb_connection_t *xcb_conn = XGetXCBConnection (x11_display->xdisplay);
xcb_generic_error_t *e;
g_autofree xcb_generic_error_t *e = NULL;
g_autofree xcb_get_window_attributes_reply_t *attrs =
xcb_get_window_attributes_reply (xcb_conn,
xcb_get_window_attributes (xcb_conn, group_leader),
&e);
if (e)
if (e || !attrs)
return NULL;
const uint32_t events[] = { attrs->your_event_mask | XCB_EVENT_MASK_PROPERTY_CHANGE };

View File

@ -191,16 +191,13 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
xcb_get_property_cookie_t cookie,
GetPropertyResults *results)
{
xcb_get_property_reply_t *reply;
xcb_generic_error_t *error;
g_autofree xcb_get_property_reply_t *reply = NULL;
g_autofree xcb_generic_error_t *error = NULL;
int length;
reply = xcb_get_property_reply (xcb_conn, cookie, &error);
if (error)
{
free (error);
return FALSE;
}
if (error || !reply)
return FALSE;
results->n_items = reply->value_len;
results->type = reply->type;
@ -219,7 +216,6 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
results->prop[length] = '\0';
}
free (reply);
return (results->prop != NULL);
}