rtpptdemux: plug pad leak in error code path
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 13 Jan 2012 10:32:59 +0000 (10:32 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 13 Jan 2012 11:02:24 +0000 (11:02 +0000)
Based on patch by: Stig Sandnes <stig.sandnes@cisco.com>

Don't leak srcpad if there are no caps.

https://bugzilla.gnome.org/show_bug.cgi?id=667820

gst/rtpmanager/gstrtpptdemux.c

index 0679438..630212f 100644 (file)
@@ -326,6 +326,10 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
     GstPadTemplate *templ;
     gchar *padname;
 
+    caps = gst_rtp_pt_demux_get_caps (rtpdemux, pt);
+    if (!caps)
+      goto no_caps;
+
     klass = GST_ELEMENT_GET_CLASS (rtpdemux);
     templ = gst_element_class_get_pad_template (klass, "src_%d");
     padname = g_strdup_printf ("src_%d", pt);
@@ -334,10 +338,6 @@ gst_rtp_pt_demux_chain (GstPad * pad, GstBuffer * buf)
     g_free (padname);
     gst_pad_set_event_function (srcpad, gst_rtp_pt_demux_src_event);
 
-    caps = gst_rtp_pt_demux_get_caps (rtpdemux, pt);
-    if (!caps)
-      goto no_caps;
-
     caps = gst_caps_make_writable (caps);
     gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL);
     gst_pad_set_caps (srcpad, caps);