]> Pileus Git - ~andy/gtk/commitdiff
Bug 657770 - Write to released memory in gtkdnd-quartz.c
authorKristian Rietveld <kris@gtk.org>
Sun, 25 Sep 2011 00:32:21 +0000 (17:32 -0700)
committerJohn Ralls <jralls@ceridwen.us>
Sun, 9 Oct 2011 17:37:21 +0000 (10:37 -0700)
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

index b577bb6f105ae4a6d808d6c2b70b87643c773c0f..6d4e709a94851e806cf6c7221d139cd01746247d 100644 (file)
@@ -1777,6 +1777,9 @@ gtk_drag_set_icon_default (GdkDragContext    *context)
 static void
 gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
 {
+  NSPasteboard *pasteboard;
+  NSAutoreleasePool *pool;
+
   if (info->icon_pixbuf)
     g_object_unref (info->icon_pixbuf);
 
@@ -1791,10 +1794,21 @@ 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);
 
   g_free (info);
+  info = NULL;
 }
 
 static gboolean