From: Wim Taymans Date: Sat, 2 Feb 2002 00:22:34 +0000 (+0000) Subject: Fix a serious leak in tee X-Git-Tag: RELEASE-0_3_2-DOBDAY~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b37f73757a4a227a0973829f083e7b88a27faf0c;p=platform%2Fupstream%2Fgstreamer.git Fix a serious leak in tee Original commit message from CVS: Fix a serious leak in tee --- diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index c2702e0..5bddebe 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -115,7 +115,7 @@ gst_tee_class_init (GstTeeClass *klass) gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad); } -static gboolean +static GstPadConnectReturn gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) { GstTee *tee; @@ -123,6 +123,10 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) tee = GST_TEE (gst_pad_get_parent (pad)); + if (!GST_CAPS_IS_FIXED (caps)) { + return GST_PAD_CONNECT_DELAYED; + } + /* go through all the src pads */ pads = gst_element_get_pad_list (GST_ELEMENT (tee)); @@ -134,10 +138,10 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) continue; if (!(gst_pad_try_set_caps (outpad, caps))) { - return FALSE; + return GST_PAD_CONNECT_REFUSED; } } - return TRUE; + return GST_PAD_CONNECT_OK; } static void @@ -261,7 +265,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf) tee = GST_TEE (gst_pad_get_parent (pad)); /* gst_trace_add_entry (NULL, 0, buf, "tee buffer");*/ - gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads); + gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1); pads = gst_element_get_pad_list (GST_ELEMENT (tee)); diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index c2702e0..5bddebe 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -115,7 +115,7 @@ gst_tee_class_init (GstTeeClass *klass) gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad); } -static gboolean +static GstPadConnectReturn gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) { GstTee *tee; @@ -123,6 +123,10 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) tee = GST_TEE (gst_pad_get_parent (pad)); + if (!GST_CAPS_IS_FIXED (caps)) { + return GST_PAD_CONNECT_DELAYED; + } + /* go through all the src pads */ pads = gst_element_get_pad_list (GST_ELEMENT (tee)); @@ -134,10 +138,10 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) continue; if (!(gst_pad_try_set_caps (outpad, caps))) { - return FALSE; + return GST_PAD_CONNECT_REFUSED; } } - return TRUE; + return GST_PAD_CONNECT_OK; } static void @@ -261,7 +265,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf) tee = GST_TEE (gst_pad_get_parent (pad)); /* gst_trace_add_entry (NULL, 0, buf, "tee buffer");*/ - gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads); + gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1); pads = gst_element_get_pad_list (GST_ELEMENT (tee));