[gtk+/gtk-2-24-quartz] Bug 657770 - Write to released memory in gtkdnd-quartz.c



commit a6a3e112259e29a673d8a6d660316c160a5f1100
Author: Kristian Rietveld <kris gtk org>
Date:   Sat Sep 24 17:32:21 2011 -0700

    Bug 657770 - Write to released memory in gtkdnd-quartz.c
    
    Clear the Drag paste board just before the info->context is released.
    This way the GtkDragSourceOwner is released just before the drag context
    is and thus can pasteboard:provideDataForType: not accidentally access
    an already released drag context

 gtk/gtkdnd-quartz.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 2b5856c..6b9fb9a 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1884,6 +1884,9 @@ gtk_drag_set_default_icon (GdkColormap   *colormap,
 static void
 gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
 {
+  NSPasteboard *pasteboard;
+  NSAutoreleasePool *pool;
+
   if (info->icon_pixbuf)
     g_object_unref (info->icon_pixbuf);
 
@@ -1898,6 +1901,16 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
 
   gtk_target_list_unref (info->target_list);
 
+  pool = [[NSAutoreleasePool alloc] init];
+
+  /* Empty the pasteboard, so that it will not accidentally access
+   * info->context after it has been destroyed.
+   */
+  pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard];
+  [pasteboard declareTypes: nil owner: nil];
+
+  [pool relase];
+
   gtk_drag_clear_source_info (info->context);
   g_object_unref (info->context);
 



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