From 8e3c67b6df520625e20d1faebd4c6015525aed0e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 17 May 2003 16:09:59 +0000 Subject: make wavparse not segfault when somebody puts data at the end of the file Original commit message from CVS: make wavparse not segfault when somebody puts data at the end of the file --- gst/wavparse/gstwavparse.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'gst/wavparse/gstwavparse.c') diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index 47884944..3dcfacf3 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -243,8 +243,10 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) /* we can't go beyond the max length */ maxsize = wavparse->riff_nextlikely - GST_BUFFER_OFFSET (buf); - /* if we're expected to see a new chunk in this buffer */ - if (maxsize < size) { + if (maxsize == 0) { + return; + } else if (maxsize < size) { + /* if we're expected to see a new chunk in this buffer */ GstBuffer *newbuf; newbuf = gst_buffer_create_sub (buf, 0, maxsize); @@ -267,7 +269,7 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) &GST_BUFFER_TIMESTAMP (buf)); if (wavparse->need_discont) { - if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { + if (buf && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { gst_pad_push (wavparse->srcpad, GST_BUFFER (gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, wavparse->offset, @@ -282,9 +284,9 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) wavparse->need_discont = FALSE; } gst_pad_push (wavparse->srcpad, buf); - } - else + } else { gst_buffer_unref (buf); + } wavparse->offset += size; -- cgit