From 73fac6e4ea5df98afc5a04cc267b0a89b1b10ad4 Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Thu, 12 Mar 2009 16:10:25 +0100 Subject: Don't call FLAC__ methods before it's initialized. Fixes #516031 In the event handler, gst_flac_dec_sink_event(), two functions are called on the FLAC stream without checking if it has been initialized: FLAC__stream_decoder_flush() FLAC__stream_decoder_process_until_end_of_stream() Both these FLAC__*() functions modify the internal state of the FLAC stream. Later, when the buffers start flowing, gst_flac_dec_chain() tries to initialize the stream. the FLAC__stream_decoder_init_stream() call will fail because the previous calls to FLAC__*() changed the stream state so it is no longer in the initialized state. --- ext/flac/gstflacdec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index adc4f355..408301f5 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -1410,7 +1410,7 @@ gst_flac_dec_sink_event (GstPad * pad, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_FLUSH_STOP:{ - if (dec->stream_decoder) { + if (dec->init == FALSE) { FLAC__stream_decoder_flush (dec->stream_decoder); gst_adapter_clear (dec->adapter); } @@ -1459,10 +1459,13 @@ gst_flac_dec_sink_event (GstPad * pad, GstEvent * event) case GST_EVENT_EOS:{ GST_LOG_OBJECT (dec, "EOS, with %u bytes available in adapter", gst_adapter_available (dec->adapter)); - if (gst_adapter_available (dec->adapter) > 0) { - FLAC__stream_decoder_process_until_end_of_stream (dec->stream_decoder); + if (dec->init == FALSE) { + if (gst_adapter_available (dec->adapter) > 0) { + FLAC__stream_decoder_process_until_end_of_stream (dec-> + stream_decoder); + } + FLAC__stream_decoder_flush (dec->stream_decoder); } - FLAC__stream_decoder_flush (dec->stream_decoder); gst_adapter_clear (dec->adapter); res = gst_pad_push_event (dec->srcpad, event); break; -- cgit