[farsight2/master] Fix various memory leaks (thanks valgrind)

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


---
 gst/fsrtpconference/fs-rtp-codec-negotiation.c |    2 +-
 gst/fsrtpconference/fs-rtp-conference.c        |    4 ++++
 gst/fsrtpconference/fs-rtp-session.c           |   20 +++++++++-----------
 tests/check/main/generic.c                     |    1 +
 tests/check/main/rtpconference.c               |    2 ++
 5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-codec-negotiation.c b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
index 5e9cc12..3615a6b 100644
--- a/gst/fsrtpconference/fs-rtp-codec-negotiation.c
+++ b/gst/fsrtpconference/fs-rtp-codec-negotiation.c
@@ -539,7 +539,7 @@ negotiate_codecs (const GList *remote_codecs,
       CodecAssociation *new_ca = g_new0 (CodecAssociation, 1);
       gchar *tmp;
 
-      new_ca->codec = fs_codec_copy (nego_codec);
+      new_ca->codec = nego_codec;
       new_ca->blueprint = local_ca->blueprint;
       tmp = fs_codec_to_string (nego_codec);
       GST_DEBUG ("Negotiated codec %s", tmp);
diff --git a/gst/fsrtpconference/fs-rtp-conference.c b/gst/fsrtpconference/fs-rtp-conference.c
index 07f9073..aaf96dc 100644
--- a/gst/fsrtpconference/fs-rtp-conference.c
+++ b/gst/fsrtpconference/fs-rtp-conference.c
@@ -550,7 +550,11 @@ fs_rtp_conference_new_participant (FsBaseConference *conf,
 
     g_object_get (item->data, "cname", &lcname, NULL);
     if (!strcmp (lcname, cname))
+    {
+      g_free (lcname);
         break;
+    }
+    g_free (lcname);
   }
   GST_OBJECT_UNLOCK (self);
 
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 02ae40c..a099818 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -500,6 +500,9 @@ fs_rtp_session_finalize (GObject *object)
   if (self->priv->negotiated_codec_associations)
     g_hash_table_destroy (self->priv->negotiated_codec_associations);
 
+  if (self->priv->current_send_codec)
+    fs_codec_destroy (self->priv->current_send_codec);
+
   parent_class->finalize (object);
 }
 
@@ -1197,7 +1200,7 @@ _get_request_pad_and_link (GstElement *tee_funnel, const gchar *tee_funnel_name,
     g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
       "Can not get the %s pad from the transmitter %s element",
       requestpad_name, tee_funnel_name);
-    goto error;
+    return FALSE;
   }
 
   transpad = gst_element_get_static_pad (sinksrc, sinksrc_padname);
@@ -1207,25 +1210,17 @@ _get_request_pad_and_link (GstElement *tee_funnel, const gchar *tee_funnel_name,
   else
     ret = gst_pad_link (transpad, requestpad);
 
+  gst_object_unref (requestpad);
   gst_object_unref (transpad);
 
   if (GST_PAD_LINK_FAILED(ret)) {
     g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
       "Can not link the %s to the transmitter %s", tee_funnel_name,
       (direction == GST_PAD_SINK) ? "sink" : "src");
-    goto error;
+    return FALSE;
   }
 
   return TRUE;
-
- error:
-  if (requestpad)
-  {
-    gst_element_release_request_pad (tee_funnel, requestpad);
-    gst_object_unref (requestpad);
-  }
-
-  return FALSE;
 }
 
 /**
@@ -2125,6 +2120,7 @@ fs_rtp_session_verify_send_codec_bin_locked (FsRtpSession *self, GError **error)
     if (fs_codec_are_equal (codec, self->priv->current_send_codec))
     {
       ret = TRUE;
+      fs_codec_destroy (codec);
       goto done;
     }
 
@@ -2228,8 +2224,10 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
     if (!strcmp (localcname, cname))
     {
       stream = localstream;
+      g_free (localcname);
       break;
     }
+    g_free (localcname);
   }
 
   if (!stream) {
diff --git a/tests/check/main/generic.c b/tests/check/main/generic.c
index 5ca46b2..89fea8e 100644
--- a/tests/check/main/generic.c
+++ b/tests/check/main/generic.c
@@ -97,6 +97,7 @@ cleanup_simple_stream (struct SimpleTestStream *st)
 {
   g_object_unref (st->stream);
   g_object_unref (st->participant);
+  g_free (st);
 }
 
 void
diff --git a/tests/check/main/rtpconference.c b/tests/check/main/rtpconference.c
index a179eea..ad53043 100644
--- a/tests/check/main/rtpconference.c
+++ b/tests/check/main/rtpconference.c
@@ -68,12 +68,14 @@ GST_START_TEST (test_rtpconference_new)
 
   fail_unless (id == 1, "The id of the first session should be 1 not %d", id);
   fail_if (local_codecs == NULL, "Local codecs should not be NULL");
+  fs_codec_list_destroy (local_codecs);
   fail_unless (media_type == FS_MEDIA_TYPE_AUDIO, "Media type isnt audio,"
       " its %d", media_type);
   fail_if (sinkpad == NULL, "Sink pad should not be null");
   str = g_strdup_printf ("sink_%d", id);
   fail_unless (!strcmp (str, GST_OBJECT_NAME (sinkpad)), "Sink pad is %s"
       " instead of being %d", GST_OBJECT_NAME (sinkpad), str);
+  gst_object_unref (sinkpad);
   g_free (str);
   fail_unless (conf == dat->conference, "Conference pointer from the session"
       " is wrong");
-- 
1.5.6.5




More information about the farsight-commits mailing list