[tracker/rss-enclosures] Fixes GB#624747 and NB#179434: Avoid double-free in send_and_splice_async_callback()



commit ed29dc9f175a4522659c560a52f42ea7bd5c3748
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Jul 19 20:27:11 2010 +0200

    Fixes GB#624747 and NB#179434: Avoid double-free in send_and_splice_async_callback()

 src/libtracker-client/tracker.c      |    4 ++++
 src/libtracker-common/tracker-dbus.c |    5 ++++-
 src/miners/fs/tracker-miner-files.c  |    2 ++
 3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 93ca79f..681d676 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -668,6 +668,10 @@ callback_iterator (void     *buffer,
 
 			g_error_free (iterator_error);
 		}
+
+		/* Always free input GError. We want to behave exactly as if this
+		 * callback were one used in an async dbus-glib query.  */
+		g_error_free (error);
 	}
 
 	fast_async_data_free (fad);
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index f18c6f9..0876013 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -861,7 +861,10 @@ send_and_splice_async_callback (GObject      *source,
 
 			(* data->callback) (NULL, -1, error, data->user_data);
 
-			g_error_free (error);
+			/* Note: GError should be freed by callback. We do this to be aligned
+			 * with the behavior of dbus-glib, where if an error happens, the
+			 * GError passed to the callback is supposed to be disposed by the
+			 * callback itself. */
 		} else {
 			dbus_pending_call_cancel (data->call);
 			(* data->callback) (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->output_stream)),
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index b4bd316..9fbbd86 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -1886,6 +1886,8 @@ extractor_get_embedded_metadata_cb (DBusGProxy *proxy,
 		/* Something bad happened, notify about the error */
 		tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
 		process_file_data_free (data);
+		/* Always free input GError. We want to behave exactly as if this
+		 * callback were one used in an async dbus-glib query.  */
 		g_error_free (error);
 		return;
 	}



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