[farsight2/master] Fix memory leak in multicast stream transmitter

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:21:07 PST 2008


---
 .../multicast/fs-multicast-stream-transmitter.c    |   15 ++++++++++++++-
 transmitters/multicast/fs-multicast-transmitter.c  |    2 ++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/transmitters/multicast/fs-multicast-stream-transmitter.c b/transmitters/multicast/fs-multicast-stream-transmitter.c
index 1dd2417..04656ba 100644
--- a/transmitters/multicast/fs-multicast-stream-transmitter.c
+++ b/transmitters/multicast/fs-multicast-stream-transmitter.c
@@ -284,6 +284,18 @@ fs_multicast_stream_transmitter_finalize (GObject *object)
     self->priv->remote_candidate = NULL;
   }
 
+  if (self->priv->local_candidate)
+  {
+    for (c = 1; c <= self->priv->transmitter->components; c++)
+    {
+      if (self->priv->local_candidate[c])
+        fs_candidate_destroy (self->priv->local_candidate[c]);
+      self->priv->local_candidate[c] = NULL;
+    }
+    g_free (self->priv->local_candidate);
+    self->priv->local_candidate = NULL;
+  }
+
   g_free (self->priv->sendmcasts);
   self->priv->sendmcasts = NULL;
 
@@ -418,7 +430,8 @@ fs_multicast_stream_transmitter_build (FsMulticastStreamTransmitter *self,
       return FALSE;
     }
 
-    self->priv->local_candidate[candidate->component_id] = candidate;
+    self->priv->local_candidate[candidate->component_id] =
+      fs_candidate_copy (candidate);
   }
 
   for (c = 1; c <= self->priv->transmitter->components; c++)
diff --git a/transmitters/multicast/fs-multicast-transmitter.c b/transmitters/multicast/fs-multicast-transmitter.c
index 50dfee0..32d235c 100644
--- a/transmitters/multicast/fs-multicast-transmitter.c
+++ b/transmitters/multicast/fs-multicast-transmitter.c
@@ -929,6 +929,7 @@ fs_multicast_transmitter_get_group (FsMulticastTransmitter *trans,
 
     if (!strcmp (mcast->multicast_ip, multicast_ip))
     {
+      fs_multicast_transmitter_put_udpport (trans, mcast->udpport);
       mcast->refcount++;
       return mcast;
     }
@@ -979,6 +980,7 @@ fs_multicast_transmitter_get_group (FsMulticastTransmitter *trans,
 
   if (mcast)
   {
+    fs_multicast_transmitter_put_udpport (trans, mcast->udpport);
     g_free (mcast->multicast_ip);
     g_free (mcast);
   }
-- 
1.5.6.5




More information about the farsight-commits mailing list