[metacity/redhat-1888993] window: fix crash in get_client_pid




commit 63ffb49f5b6ad7628c12436b75058c0c6976ef8e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Oct 17 20:38:28 2020 +0300

    window: fix crash in get_client_pid
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1888993

 src/core/window.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 171b1705..3083a6be 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -9283,16 +9283,28 @@ meta_window_get_client_pid (MetaWindow *self)
       XResClientIdSpec spec;
       long num_ids;
       XResClientIdValue *client_ids;
+      Status status;
+      int result;
       long i;
 
       spec.client = self->xwindow;
       spec.mask = XRES_CLIENT_ID_PID_MASK;
 
-      XResQueryClientIds (self->display->xdisplay,
-                          1,
-                          &spec,
-                          &num_ids,
-                          &client_ids);
+      num_ids = 0;
+      client_ids = NULL;
+
+      meta_error_trap_push (self->display);
+
+      status = XResQueryClientIds (self->display->xdisplay,
+                                   1,
+                                   &spec,
+                                   &num_ids,
+                                   &client_ids);
+
+      result = meta_error_trap_pop_with_return (self->display);
+
+      if (status != Success || result != Success)
+        return -1;
 
       for (i = 0; i < num_ids; i++)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]