Commit 8e3c67b6 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

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
parent 01d4e568
...@@ -243,8 +243,10 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) ...@@ -243,8 +243,10 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
/* we can't go beyond the max length */ /* we can't go beyond the max length */
maxsize = wavparse->riff_nextlikely - GST_BUFFER_OFFSET (buf); maxsize = wavparse->riff_nextlikely - GST_BUFFER_OFFSET (buf);
/* if we're expected to see a new chunk in this buffer */ if (maxsize == 0) {
if (maxsize < size) { return;
} else if (maxsize < size) {
/* if we're expected to see a new chunk in this buffer */
GstBuffer *newbuf; GstBuffer *newbuf;
newbuf = gst_buffer_create_sub (buf, 0, maxsize); newbuf = gst_buffer_create_sub (buf, 0, maxsize);
...@@ -267,7 +269,7 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) ...@@ -267,7 +269,7 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
&GST_BUFFER_TIMESTAMP (buf)); &GST_BUFFER_TIMESTAMP (buf));
if (wavparse->need_discont) { 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_pad_push (wavparse->srcpad,
GST_BUFFER (gst_event_new_discontinuous (FALSE, GST_BUFFER (gst_event_new_discontinuous (FALSE,
GST_FORMAT_BYTES, wavparse->offset, GST_FORMAT_BYTES, wavparse->offset,
...@@ -282,9 +284,9 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) ...@@ -282,9 +284,9 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
wavparse->need_discont = FALSE; wavparse->need_discont = FALSE;
} }
gst_pad_push (wavparse->srcpad, buf); gst_pad_push (wavparse->srcpad, buf);
} } else {
else
gst_buffer_unref (buf); gst_buffer_unref (buf);
}
wavparse->offset += size; wavparse->offset += size;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment