[gtk+/quartz-integration: 30/35] Bug 657770 -- Write releaseed memory in gtkdnd-quartz.c
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/quartz-integration: 30/35] Bug 657770 -- Write releaseed memory in gtkdnd-quartz.c
- Date: Thu, 1 Sep 2011 06:32:00 +0000 (UTC)
commit c6b9dfead662d8da5d0d246862fc53d474e40580
Author: John Ralls <jralls ceridwen us>
Date: Tue Aug 30 16:00:43 2011 -0700
Bug 657770 -- Write releaseed memory in gtkdnd-quartz.c
Changes the GtkDragSourceOwner class to keep a copy of the
source GdkDragContext instead of the GtkDragSourceInfo that's attached
to it as qdata. Get the drag_source_info from the context qdata instead.
Since ordinarily the info (and the context, for that matter) are freed
*before* pasteboardChangeOwner gets called, check that the context is
the same as the current _gdk_quartz_drag_source_context and if they
don't match, NULL the member one and return rather than trying to NULL
info members; if info is NULL, return rather than trying to dereference
it. This prevents accessing the already-freed info structure and
context.
Set the info pointer to NULL after clearing its contents and freeing
it (probably unnecessary, but cheap insurance).
gtk/gtkdnd-quartz.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index c26c0c5..74dbbf4 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -132,7 +132,7 @@ struct _GtkDragFindData
@interface GtkDragSourceOwner : NSObject {
- GtkDragSourceInfo *info;
+ GdkDragContext *context;
}
@end
@@ -142,6 +142,10 @@ struct _GtkDragFindData
{
guint target_info;
GtkSelectionData selection_data;
+ GtkDragSourceInfo *info;
+ g_return_if_fail (context != NULL);
+ info = gtk_drag_get_source_info (context, FALSE);
+ g_return_if_fail (info != NULL);
g_return_if_fail(info->source_widget != NULL);
g_return_if_fail(info->target_list != NULL);
selection_data.selection = GDK_NONE;
@@ -169,18 +173,29 @@ struct _GtkDragFindData
- (void)pasteboardChangedOwner: (NSPasteboard*)sender
{
+ GtkDragSourceInfo *info;
+
+ if (context != gdk_quartz_drag_source_context())
+ {
+ context = NULL;
+ return;
+ }
+ info = gtk_drag_get_source_info (context, FALSE);
+
+ if (!info) return;
+
info->target_list = NULL;
info->widget = NULL;
info->source_widget = NULL;
}
-- (id)initWithInfo:(GtkDragSourceInfo *)anInfo
+- (id)initWithContext:(GdkDragContext *)aContext;
{
self = [super init];
if (self)
{
- info = anInfo;
+ context = aContext;
}
return self;
@@ -1070,10 +1085,11 @@ gtk_drag_begin_idle (gpointer arg)
g_assert (info != NULL);
pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- owner = [[GtkDragSourceOwner alloc] initWithInfo:info];
+ owner = [[GtkDragSourceOwner alloc] initWithContext:context];
types = _gtk_quartz_target_list_to_pasteboard_types (info->target_list);
+ /* This sends a pasteboardChangedOwner: notification to the old owner */
[pasteboard declareTypes:[types allObjects] owner:owner];
[owner release];
@@ -1800,6 +1816,7 @@ gtk_drag_set_icon_default (GdkDragContext *context)
static void
gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
{
+
if (info->icon_pixbuf)
g_object_unref (info->icon_pixbuf);
@@ -1818,6 +1835,7 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
g_object_unref (info->context);
g_free (info);
+ info = NULL;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]