From 377c8405aaf66fa4055f1a387a21c9e1ea502838 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 30 Apr 2015 12:13:59 +0100 Subject: [PATCH] qtdemux: fix buffer leak on eos in push mode Based on patch by Guillaume Desmottes. scenario: validate.http.playback.seek_with_stop.raw_h264_1_mp4 https://bugzilla.gnome.org/show_bug.cgi?id=748617 --- gst/isomp4/qtdemux.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 80f7ae3..bc8a500 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -5345,7 +5345,6 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force) break; } case QTDEMUX_STATE_MOVIE:{ - GstBuffer *outbuf; QtDemuxStream *stream = NULL; QtDemuxSample *sample; int i = -1; @@ -5440,12 +5439,9 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force) sample = &stream->samples[stream->sample_index]; if (G_LIKELY (!(STREAM_IS_EOS (stream)))) { - outbuf = gst_adapter_take_buffer (demux->adapter, demux->neededbytes); GST_DEBUG_OBJECT (demux, "stream : %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (stream->fourcc)); - g_return_val_if_fail (outbuf != NULL, GST_FLOW_ERROR); - dts = QTSAMPLE_DTS (stream, sample); pts = QTSAMPLE_PTS (stream, sample); duration = QTSAMPLE_DUR_DTS (stream, sample, dts); @@ -5457,6 +5453,9 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force) GST_DEBUG_OBJECT (demux, "we reached the end of our segment."); stream->time_position = GST_CLOCK_TIME_NONE; /* this means EOS */ + /* skip this data, stream is EOS */ + gst_adapter_flush (demux->adapter, demux->neededbytes); + /* check if all streams are eos */ ret = GST_FLOW_EOS; for (i = 0; i < demux->n_streams; i++) { @@ -5471,6 +5470,14 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force) goto eos; } } else { + GstBuffer *outbuf; + + outbuf = + gst_adapter_take_buffer (demux->adapter, demux->neededbytes); + + /* FIXME: should either be an assert or a plain check */ + g_return_val_if_fail (outbuf != NULL, GST_FLOW_ERROR); + ret = gst_qtdemux_decorate_and_push_buffer (demux, stream, outbuf, dts, pts, duration, keyframe, dts, demux->offset); } -- 2.7.4