mirror of
https://github.com/brl/mutter.git
synced 2025-03-31 15:43:48 +00:00
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:
parent
9b8cff8673
commit
445373d028
@ -56,12 +56,12 @@ meta_group_new (MetaX11Display *x11_display,
|
|||||||
group->refcount = 1; /* owned by caller, hash table has only weak ref */
|
group->refcount = 1; /* owned by caller, hash table has only weak ref */
|
||||||
|
|
||||||
xcb_connection_t *xcb_conn = XGetXCBConnection (x11_display->xdisplay);
|
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 =
|
g_autofree xcb_get_window_attributes_reply_t *attrs =
|
||||||
xcb_get_window_attributes_reply (xcb_conn,
|
xcb_get_window_attributes_reply (xcb_conn,
|
||||||
xcb_get_window_attributes (xcb_conn, group_leader),
|
xcb_get_window_attributes (xcb_conn, group_leader),
|
||||||
&e);
|
&e);
|
||||||
if (e)
|
if (e || !attrs)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
const uint32_t events[] = { attrs->your_event_mask | XCB_EVENT_MASK_PROPERTY_CHANGE };
|
const uint32_t events[] = { attrs->your_event_mask | XCB_EVENT_MASK_PROPERTY_CHANGE };
|
||||||
|
@ -191,16 +191,13 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
|
|||||||
xcb_get_property_cookie_t cookie,
|
xcb_get_property_cookie_t cookie,
|
||||||
GetPropertyResults *results)
|
GetPropertyResults *results)
|
||||||
{
|
{
|
||||||
xcb_get_property_reply_t *reply;
|
g_autofree xcb_get_property_reply_t *reply = NULL;
|
||||||
xcb_generic_error_t *error;
|
g_autofree xcb_generic_error_t *error = NULL;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
reply = xcb_get_property_reply (xcb_conn, cookie, &error);
|
reply = xcb_get_property_reply (xcb_conn, cookie, &error);
|
||||||
if (error)
|
if (error || !reply)
|
||||||
{
|
return FALSE;
|
||||||
free (error);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
results->n_items = reply->value_len;
|
results->n_items = reply->value_len;
|
||||||
results->type = reply->type;
|
results->type = reply->type;
|
||||||
@ -219,7 +216,6 @@ async_get_property_finish (xcb_connection_t *xcb_conn,
|
|||||||
results->prop[length] = '\0';
|
results->prop[length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
free (reply);
|
|
||||||
return (results->prop != NULL);
|
return (results->prop != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user