From 009c9750ea535fca5fea1df3fbaf7aa691e962e6 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Tue, 6 Mar 2007 23:19:30 +0000 Subject: gst/id3demux/gstid3demux.c: Don't leak caps: make gst_id3demux_add_srcpad() not take ownership of the caps passed to ... Original commit message from CVS: * gst/id3demux/gstid3demux.c: (gst_id3demux_add_srcpad), (gst_id3demux_sink_activate): Don't leak caps: make gst_id3demux_add_srcpad() not take ownership of the caps passed to it (previouslly one code path assumes it takes ownership while another one assumes it doesn't). * configure.ac: * tests/files/Makefile.am: * tests/files/id3-407349-1.tag: * tests/files/id3-407349-2.tag: Add directory where data for unit tests can be stored. * tests/Makefile.am: * tests/check/Makefile.am: * tests/check/elements/.cvsignore: * tests/check/elements/id3demux.c: (pad_added_cb), (error_cb), (read_tags_from_file), (run_check_for_file), (check_date_1977_06_23), (GST_START_TEST), (id3demux_suite): Add unit test for id3demux, and in particular for bug #407349. Only testing pull-mode for now; push mode doesn't work yet because the test files are smaller than ID3_TYPE_FIND_MIN_SIZE. --- gst/id3demux/gstid3demux.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gst/id3demux') diff --git a/gst/id3demux/gstid3demux.c b/gst/id3demux/gstid3demux.c index 469514f9..886264f6 100644 --- a/gst/id3demux/gstid3demux.c +++ b/gst/id3demux/gstid3demux.c @@ -106,7 +106,7 @@ static GstFlowReturn gst_id3demux_src_getrange (GstPad * srcpad, guint64 offset, guint length, GstBuffer ** buffer); static gboolean gst_id3demux_add_srcpad (GstID3Demux * id3demux, - GstCaps * new_caps); + const GstCaps * new_caps); static gboolean gst_id3demux_remove_srcpad (GstID3Demux * id3demux); static gboolean gst_id3demux_srcpad_event (GstPad * pad, GstEvent * event); @@ -239,12 +239,12 @@ gst_id3demux_dispose (GObject * object) } static gboolean -gst_id3demux_add_srcpad (GstID3Demux * id3demux, GstCaps * new_caps) +gst_id3demux_add_srcpad (GstID3Demux * id3demux, const GstCaps * new_caps) { if (id3demux->src_caps == NULL || !gst_caps_is_equal (new_caps, id3demux->src_caps)) { - gst_caps_replace (&(id3demux->src_caps), new_caps); + gst_caps_replace (&(id3demux->src_caps), (GstCaps *) new_caps); if (id3demux->srcpad != NULL) { GST_DEBUG_OBJECT (id3demux, "Changing src pad caps to %" GST_PTR_FORMAT, id3demux->src_caps); @@ -252,8 +252,7 @@ gst_id3demux_add_srcpad (GstID3Demux * id3demux, GstCaps * new_caps) gst_pad_set_caps (id3demux->srcpad, id3demux->src_caps); } } else { - /* Caps never changed */ - gst_caps_unref (new_caps); + /* caps didn't change */ } if (id3demux->srcpad == NULL) { @@ -909,7 +908,6 @@ gst_id3demux_sink_activate (GstPad * sinkpad) id3demux->state = GST_ID3DEMUX_STREAMING; /* 6 Add the srcpad for output now we know caps. */ - /* add_srcpad takes ownership of the caps */ if (!gst_id3demux_add_srcpad (id3demux, caps)) { GST_DEBUG_OBJECT (id3demux, "Could not add source pad"); goto done_activate; @@ -925,6 +923,9 @@ gst_id3demux_sink_activate (GstPad * sinkpad) done_activate: + if (caps) + gst_caps_unref (caps); + return ret; } -- cgit