[gtk+] Fix some possible crashes if the default display is NULL



commit 9e6d3d969cd314093e161a3c1feba1612ed403bc
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Apr 8 21:20:26 2011 -0400

    Fix some possible crashes if the default display is NULL
    
    Unlikely that many people will hit these, but still.
    https://bugzilla.gnome.org/show_bug.cgi?id=645176

 gdk/gdkdisplay.c                |    3 ++-
 gdk/gdkevents.c                 |    6 +++++-
 gdk/x11/gdkdisplaymanager-x11.c |    3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 1b8c7e7..f2c95f7 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -134,7 +134,8 @@ gdk_display_class_init (GdkDisplayClass *class)
 static void
 free_pointer_info (GdkPointerWindowInfo *info)
 {
-  g_object_unref (info->toplevel_under_pointer);
+  if (info->toplevel_under_pointer)
+    g_object_unref (info->toplevel_under_pointer);
   g_slice_free (GdkPointerWindowInfo, info);
 }
 
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 25853da..29dff07 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -605,6 +605,8 @@ gdk_event_copy (const GdkEvent *event)
 void
 gdk_event_free (GdkEvent *event)
 {
+  GdkDisplay *display;
+
   g_return_if_fail (event != NULL);
 
   if (event->any.window)
@@ -670,7 +672,9 @@ gdk_event_free (GdkEvent *event)
       break;
     }
 
-  _gdk_display_event_data_free (gdk_display_get_default (), event);
+  display = gdk_display_get_default ();
+  if (display)
+    _gdk_display_event_data_free (display, event);
 
   g_hash_table_remove (event_hash, event);
   g_slice_free (GdkEventPrivate, (GdkEventPrivate*) event);
diff --git a/gdk/x11/gdkdisplaymanager-x11.c b/gdk/x11/gdkdisplaymanager-x11.c
index fbd4946..c5a3728 100644
--- a/gdk/x11/gdkdisplaymanager-x11.c
+++ b/gdk/x11/gdkdisplaymanager-x11.c
@@ -77,7 +77,8 @@ gdk_x11_display_manager_set_default_display (GdkDisplayManager *manager,
 {
   GDK_X11_DISPLAY_MANAGER (manager)->default_display = display;
 
-  _gdk_x11_display_make_default (display);
+  if (display)
+    _gdk_x11_display_make_default (display);
 }
 
 static void



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