[mutter/wip/carlosg/on-demand-fixes: 3/3] core: Do not crash on untimely stack queries for X11 windows



commit 85b2739fcb200fc9fb976ef914700658e6addf9b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 15 13:59:01 2019 +0200

    core: Do not crash on untimely stack queries for X11 windows
    
    Some meta_later operations may happen across XWayland being shutdown,
    that trigger MetaStackTracker queries for X11 XIDs. This crashes as
    the MetaX11Display is already NULL.
    
    Return a NULL window in that case, as in "unknown stack ID".

 src/core/display.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index fb4b127f5..3d1e33429 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1426,10 +1426,16 @@ meta_display_lookup_stack_id (MetaDisplay *display,
                               guint64      stack_id)
 {
   if (META_STACK_ID_IS_X11 (stack_id))
-    return meta_x11_display_lookup_x_window (display->x11_display,
-                                             (Window)stack_id);
+    {
+      if (!display->x11_display)
+        return NULL;
+      return meta_x11_display_lookup_x_window (display->x11_display,
+                                               (Window)stack_id);
+    }
   else
-    return meta_display_lookup_stamp (display, stack_id);
+    {
+      return meta_display_lookup_stamp (display, stack_id);
+    }
 }
 
 /* We return a pointer into a ring of static buffers. This is to make


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