[mutter] x11: Check for XCB reply
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] x11: Check for XCB reply
- Date: Tue, 9 Feb 2021 19:27:39 +0000 (UTC)
commit 445373d028c896b557d03d4f416e7a50a972cf08
Author: Olivier Fourdan <ofourdan redhat com>
Date: Mon Feb 8 18:19:01 2021 +0100
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>
src/x11/group.c | 4 ++--
src/x11/xprops.c | 12 ++++--------
2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/src/x11/group.c b/src/x11/group.c
index 57b79e96e5..27f21d0682 100644
--- a/src/x11/group.c
+++ b/src/x11/group.c
@@ -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 };
diff --git a/src/x11/xprops.c b/src/x11/xprops.c
index ad74538534..19f7a1cae0 100644
--- a/src/x11/xprops.c
+++ b/src/x11/xprops.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]