[next] telepathy-glib: TpTestsSimpleChannelDispatcher: don' t leak various struct members

Simon McVittie smcv at kemper.freedesktop.org
Thu Mar 13 07:08:35 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 56760148781a97dde5de9d4f366f00af12277810
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=56760148781a97dde5de9d4f366f00af12277810

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Mar 10 17:50:26 2014 +0000

TpTestsSimpleChannelDispatcher: don't leak various struct members

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76000
Reviewed-by: Guillaume Desmottes

---

 tests/lib/simple-channel-dispatcher.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tests/lib/simple-channel-dispatcher.c b/tests/lib/simple-channel-dispatcher.c
index 775f915..49516bb 100644
--- a/tests/lib/simple-channel-dispatcher.c
+++ b/tests/lib/simple-channel-dispatcher.c
@@ -335,13 +335,26 @@ tp_tests_simple_channel_dispatcher_dispose (GObject *object)
   g_slist_foreach (self->priv->requests, (GFunc) g_object_unref, NULL);
   g_slist_free (self->priv->requests);
 
-  g_free (self->priv->old_handler);
-
   if (G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose != NULL)
     G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose (object);
 }
 
 static void
+tp_tests_simple_channel_dispatcher_finalize (GObject *object)
+{
+  TpTestsSimpleChannelDispatcher *self = SIMPLE_CHANNEL_DISPATCHER (object);
+
+  g_clear_pointer (&self->last_request, g_hash_table_unref);
+  g_clear_pointer (&self->last_hints, g_hash_table_unref);
+  g_free (self->last_account);
+  g_free (self->last_preferred_handler);
+  g_free (self->priv->old_handler);
+
+  if (G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->finalize (object);
+}
+
+static void
 tp_tests_simple_channel_dispatcher_class_init (
     TpTestsSimpleChannelDispatcherClass *klass)
 {
@@ -367,6 +380,7 @@ tp_tests_simple_channel_dispatcher_class_init (
   object_class->set_property = tp_tests_simple_channel_dispatcher_set_property;
 
   object_class->dispose = tp_tests_simple_channel_dispatcher_dispose;
+  object_class->finalize = tp_tests_simple_channel_dispatcher_finalize;
 
   param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
       "In this case we only implement ChannelDispatcher, so none.",



More information about the telepathy-commits mailing list