[telepathy-mission-control-5.16] telepathy-mission-control: fix memory leaks: dbus_g_method_get_sender returns a copy

George Kiagiadakis gkiagia at kemper.freedesktop.org
Fri Sep 2 19:16:28 UTC 2016


Module: telepathy-mission-control
Branch: telepathy-mission-control-5.16
Commit: 43afd2866bc38efe1b2cf27989df4e36ddd21201
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=43afd2866bc38efe1b2cf27989df4e36ddd21201

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu Mar 20 12:51:18 2014 +0000

fix memory leaks: dbus_g_method_get_sender returns a copy

We were semi-consistently using it wrong.

---

 src/mcd-dispatch-operation.c | 12 ++++++------
 src/mcd-dispatcher.c         |  4 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 0f2850f..4948b6b 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -521,10 +521,7 @@ _mcd_dispatch_operation_check_client_locks (McdDispatchOperation *self)
     /* if we've been claimed, respond, then do not call HandleChannels */
     if (approval != NULL && approval->type == APPROVAL_TYPE_CLAIM)
     {
-        /* this needs to be copied because we don't use it til after we've
-         * freed approval->context */
-        gchar *caller = g_strdup (dbus_g_method_get_sender (
-            approval->context));
+        gchar *caller = dbus_g_method_get_sender (approval->context);
 
         /* remove this approval from the list, so it won't be treated as a
          * failure */
@@ -827,13 +824,16 @@ _mcd_dispatch_operation_finish (McdDispatchOperation *operation,
          approval != NULL;
          approval = g_queue_pop_head (priv->approvals))
     {
+        gchar *caller;
+
         switch (approval->type)
         {
             case APPROVAL_TYPE_CLAIM:
                 /* someone else got it - either another Claim() or a handler */
                 g_assert (approval->context != NULL);
-                DEBUG ("denying Claim call from %s",
-                       dbus_g_method_get_sender (approval->context));
+                caller = dbus_g_method_get_sender (approval->context);
+                DEBUG ("denying Claim call from %s", caller);
+                g_free (caller);
                 dbus_g_method_return_error (approval->context, priv->result);
                 approval->context = NULL;
                 break;
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 5fea7f2..2fc0828 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -2123,7 +2123,7 @@ dispatcher_delegate_channels (
 {
     McdDispatcher *self = (McdDispatcher *) iface;
     GError *error = NULL;
-    const gchar *sender;
+    gchar *sender = NULL;
     McdConnection *conn = NULL;
     DelegateChannelsCtx *ctx = NULL;
     McdAccountManager *am;
@@ -2208,11 +2208,13 @@ dispatcher_delegate_channels (
         try_delegating (to_delegate);
       }
 
+    g_free (sender);
     g_object_unref (am);
 
     return;
 
 error:
+    g_free (sender);
     dbus_g_method_return_error (context, error);
     g_error_free (error);
 



More information about the telepathy-commits mailing list