[mutter] Avoid accessing freed memory when being replaced



commit d58c9a57c68c7f774244be88faad850ceb1a9672
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Aug 22 15:55:17 2009 -0400

    Avoid accessing freed memory when being replaced
    
    If we are replaced via the window manager selection, then we close
    the MetaDisplay before meta_finalize() runs. We should be careful
    not to try to close the display again (and access already freed
    memory) in that case, so clear the global 'the_display' variable.
    
    See Metacity bug http://bugzilla.gnome.org/show_bug.cgi?id=588119
    
    http://bugzilla.gnome.org/show_bug.cgi?id=592742

 src/core/display.c |    1 +
 src/core/main.c    |    7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index f32ec62..c84673b 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1007,6 +1007,7 @@ meta_display_close (MetaDisplay *display,
     meta_compositor_destroy (display->compositor);
   
   g_object_unref (display);
+  the_display = NULL;
 
   meta_quit (META_EXIT_SUCCESS);
 }
diff --git a/src/core/main.c b/src/core/main.c
index c074b74..7aa62c9 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -427,8 +427,11 @@ meta_select_display (gchar *display_name)
 static void
 meta_finalize (void)
 {
-  meta_display_close (meta_get_display (),
-                      CurrentTime); /* I doubt correct timestamps matter here */
+  MetaDisplay *display = meta_get_display ();
+
+  if (display)
+    meta_display_close (display,
+                        CurrentTime); /* I doubt correct timestamps matter here */
 
   meta_session_shutdown ();
 }



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