[telepathy-gabble/master] plug various leaks

Dafydd Harries dafydd.harries at collabora.co.uk
Thu Dec 10 17:38:14 PST 2009


---
 src/bytestream-factory.c |    2 +-
 src/bytestream-socks5.c  |    4 +++-
 src/connection-manager.c |    1 +
 src/connection.c         |    6 +++++-
 src/ft-channel.c         |    9 +++++++++
 src/jingle-content.c     |    6 +++++-
 src/jingle-media-rtp.c   |    6 ++++++
 src/media-channel.c      |    3 +++
 src/media-factory.c      |    3 +++
 src/media-stream.c       |    7 +++++++
 src/presence-cache.c     |    1 +
 src/roster.c             |    1 +
 12 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index 771f163..908c6f9 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -2028,7 +2028,7 @@ streaminit_reply_cb (GabbleConnection *conn,
   if (!data->object_alive)
     {
       DEBUG ("Object which requested the bytestream was disposed. Ignoring");
-      return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+      goto END;
     }
 
   if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT)
diff --git a/src/bytestream-socks5.c b/src/bytestream-socks5.c
index 3923ebf..db7b60b 100644
--- a/src/bytestream-socks5.c
+++ b/src/bytestream-socks5.c
@@ -846,8 +846,9 @@ initiator_got_connect_reply (GabbleBytestreamSocks5 *self)
 
       g_signal_emit_by_name (self, "connection-error");
       g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_CLOSED, NULL);
-      return;
     }
+
+  lm_message_unref (iq);
 }
 
 /* Process the received data and returns the number of bytes that have been
@@ -1102,6 +1103,7 @@ socks5_handle_received_data (GabbleBytestreamSocks5 *self,
             DEBUG ("Reject connection to prevent spoofing");
             socks5_close_transport (self);
             socks5_error (self);
+            g_free (domain);
             return string->len;
           }
 
diff --git a/src/connection-manager.c b/src/connection-manager.c
index 68cfce4..71c96df 100644
--- a/src/connection-manager.c
+++ b/src/connection-manager.c
@@ -242,6 +242,7 @@ free_params (void *p)
   g_free (params->https_proxy_server);
   g_free (params->fallback_conference_server);
   g_free (params->stun_server);
+  g_free (params->fallback_stun_server);
   g_free (params->alias);
   g_strfreev (params->fallback_socks5_proxies);
 
diff --git a/src/connection.c b/src/connection.c
index 1d91a45..114e499 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -557,7 +557,7 @@ gabble_connection_set_property (GObject      *object,
     case PROP_RESOURCE:
       if (tp_strdiff (priv->resource, g_value_get_string (value)))
         {
-          gchar *old_resource = g_strdup (priv->resource);
+          gchar *old_resource = priv->resource;
           gchar *new_resource = g_value_dup_string (value);
 
           priv->resource = new_resource;
@@ -1065,6 +1065,7 @@ gabble_connection_finalize (GObject *object)
 
   g_free (priv->https_proxy_server);
   g_free (priv->stun_server);
+  g_free (priv->fallback_stun_server);
   g_free (priv->fallback_conference_server);
   g_strfreev (priv->fallback_socks5_proxies);
 
@@ -2701,6 +2702,9 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
 
   tp_svc_connection_interface_capabilities_return_from_advertise_capabilities (
       context, ret);
+
+out:
+  g_ptr_array_foreach (ret, (GFunc) g_value_array_free, NULL);
   g_ptr_array_free (ret, TRUE);
 }
 
diff --git a/src/ft-channel.c b/src/ft-channel.c
index ccb4d07..eff2a88 100644
--- a/src/ft-channel.c
+++ b/src/ft-channel.c
@@ -1426,6 +1426,7 @@ gabble_file_transfer_channel_accept_file (TpSvcChannelTypeFileTransfer *iface,
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
           "Channel is not an incoming transfer");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
       return;
     }
 
@@ -1434,6 +1435,7 @@ gabble_file_transfer_channel_accept_file (TpSvcChannelTypeFileTransfer *iface,
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
         "State is not pending; cannot accept file");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
       return;
     }
 
@@ -1452,6 +1454,8 @@ gabble_file_transfer_channel_accept_file (TpSvcChannelTypeFileTransfer *iface,
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
           "Could not set up local socket");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
+      return;
     }
 
   gabble_file_transfer_channel_set_state (iface,
@@ -1507,6 +1511,7 @@ gabble_file_transfer_channel_provide_file (
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
           "Channel is not an outgoing transfer");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
       return;
     }
 
@@ -1516,6 +1521,7 @@ gabble_file_transfer_channel_provide_file (
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
         "State is not pending or accepted; cannot provide file");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
       return;
     }
 
@@ -1524,6 +1530,7 @@ gabble_file_transfer_channel_provide_file (
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
           "ProvideFile has already been called for this channel");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
       return;
     }
 
@@ -1542,6 +1549,8 @@ gabble_file_transfer_channel_provide_file (
       g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
           "Could not set up local socket");
       dbus_g_method_return_error (context, error);
+      g_error_free (error);
+      return;
     }
 
   if (self->priv->remote_accepted)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index cac4c74..76a76f5 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -536,7 +536,11 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
   if (disposition == NULL)
       disposition = "session";
 
-  priv->disposition = g_strdup (disposition);
+  if (tp_strdiff (disposition, priv->disposition))
+    {
+      g_free (priv->disposition);
+      priv->disposition = g_strdup (disposition);
+    }
 
   DEBUG ("content creating new transport type %s", g_type_name (transport_type));
 
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 0aba13a..e5b0561 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -104,10 +104,15 @@ jingle_media_rtp_codec_new (guint id, const gchar *name,
   p->channels = channels;
 
   if (params != NULL)
+    {
+      g_hash_table_ref (params);
       p->params = params;
+    }
   else
+    {
       p->params = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
           g_free);
+    }
 
   return p;
 }
@@ -868,6 +873,7 @@ jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
       if (!compare_codecs (priv->local_codecs, codecs, &changed, &err))
         {
           DEBUG ("codec update was illegal: %s", err->message);
+          jingle_media_rtp_free_codecs (codecs);
           g_propagate_error (error, err);
           return FALSE;
         }
diff --git a/src/media-channel.c b/src/media-channel.c
index 0066029..05449f4 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -895,6 +895,9 @@ gabble_media_channel_dispose (GObject *object)
       g_assert (d->content == NULL);
     }
 
+  g_list_free (priv->stream_creation_datas);
+  priv->stream_creation_datas = NULL;
+
   if (priv->delayed_request_streams != NULL)
     {
       g_ptr_array_foreach (priv->delayed_request_streams,
diff --git a/src/media-factory.c b/src/media-factory.c
index ba43067..b558776 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -272,6 +272,8 @@ gabble_media_factory_close_all (GabbleMediaFactory *fac)
           priv->status_changed_id);
       priv->status_changed_id = 0;
     }
+
+  g_ptr_array_free (tmp, TRUE);
 }
 
 static void
@@ -302,6 +304,7 @@ new_jingle_session_cb (GabbleJingleFactory *jf, GabbleJingleSession *sess, gpoin
           else if (!tp_strdiff (ns, NS_JINGLE_TRANSPORT_RAWUDP))
               g_object_set (chan, "nat-traversal", "none", NULL);
 
+          g_free (ns);
           g_list_free (cs);
         }
 
diff --git a/src/media-stream.c b/src/media-stream.c
index 70833b1..45cf605 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -661,6 +661,9 @@ gabble_media_stream_dispose (GObject *object)
   g_object_unref (priv->content);
   priv->content = NULL;
 
+  g_free (self->name);
+  self->name = NULL;
+
   if (G_OBJECT_CLASS (gabble_media_stream_parent_class)->dispose)
     G_OBJECT_CLASS (gabble_media_stream_parent_class)->dispose (object);
 }
@@ -1043,6 +1046,8 @@ pass_local_codecs (GabbleMediaStream *stream,
 
       DEBUG ("adding codec %s (%u %u %u)", c->name, c->id, c->clockrate, c->channels);
       li = g_list_append (li, c);
+      g_free (name);
+      g_hash_table_unref (params);
     }
 
   return jingle_media_rtp_set_local_codecs (
@@ -1372,6 +1377,8 @@ new_remote_candidates_cb (GabbleJingleContent *content,
           G_MAXUINT);
 
       g_free (candidate_id);
+      g_value_unset (&transport);
+      g_ptr_array_free (transports, TRUE);
 
       g_ptr_array_add (candidates, g_value_get_boxed (&candidate));
     }
diff --git a/src/presence-cache.c b/src/presence-cache.c
index 4595edd..a35a048 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -1909,6 +1909,7 @@ gabble_presence_cache_caps_pending (GabblePresenceCache *cache,
         }
     }
 
+  g_list_free (uris);
   return FALSE;
 }
 
diff --git a/src/roster.c b/src/roster.c
index dd301af..5d73199 100644
--- a/src/roster.c
+++ b/src/roster.c
@@ -1553,6 +1553,7 @@ got_roster_iq (GabbleRoster *roster,
            * from them, we know they're offline. Let clients know that.
            */
           conn_presence_emit_presence_update (priv->conn, members);
+          g_array_free (members, TRUE);
         }
 
       tp_intset_destroy (pub_add);
-- 
1.5.6.5




More information about the telepathy-commits mailing list