[tracker] libtracker-common: Fix memory leak when receiving partial reply plus error in DBus sync call
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-common: Fix memory leak when receiving partial reply plus error in DBus sync call
- Date: Mon, 19 Jul 2010 21:59:35 +0000 (UTC)
commit cce47049854206260448388d9954d0c71ab364de
Author: Aleksander Morgado <aleksander lanedo com>
Date: Mon Jul 19 23:56:55 2010 +0200
libtracker-common: Fix memory leak when receiving partial reply plus error in DBus sync call
* So, we're using g_memory_output_stream_new () with a NULL destroy_function.
This means we take ownership and control of the internal buffer if the
GOutputStream. Then, if the SYNC DBus query results in an error, we won't
pass the stream->data to upper layers, so we need to explicitly free it,
or a memleak will happen.
* Same issue as in commit 2891b982414900a0844265ea831df83c9dfc9895, but for
SYNC method this time.
src/libtracker-common/tracker-dbus.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index 8f97a8b..ce2c3dd 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -773,6 +773,10 @@ tracker_dbus_send_and_splice (DBusConnection *connection,
dbus_set_error_from_message (&dbus_error, reply);
dbus_set_g_error (error, &dbus_error);
dbus_error_free (&dbus_error);
+
+ /* If any error happened, we're not passing any received data, so we
+ * need to free it */
+ g_free (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output_stream)));
} else {
*dest_buffer = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output_stream));
@@ -788,6 +792,9 @@ tracker_dbus_send_and_splice (DBusConnection *connection,
TRACKER_DBUS_ERROR_BROKEN_PIPE,
"Couldn't get results from server");
g_error_free (inner_error);
+ /* If any error happened, we're not passing any received data, so we
+ * need to free it */
+ g_free (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output_stream)));
}
g_object_unref (output_stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]