summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2006-07-16 14:46:02 +0000
committerWim Taymans <wim.taymans@gmail.com>2006-07-16 14:46:02 +0000
commita80f16883256a2576b2b29ee726d2e37eab910df (patch)
tree3d7a4cc33f8eddfd768bd9d324a460a3ad64e8e3
parenta93b6e28ca08f4b7a4a06b29103ca6184d42c679 (diff)
downloadgst-plugins-bad-a80f16883256a2576b2b29ee726d2e37eab910df.tar.gz
gst-plugins-bad-a80f16883256a2576b2b29ee726d2e37eab910df.tar.bz2
gst-plugins-bad-a80f16883256a2576b2b29ee726d2e37eab910df.zip
ext/faad/gstfaad.c: Don't crash on small buffers.
Original commit message from CVS: * ext/faad/gstfaad.c: (gst_faad_setcaps), (gst_faad_sync): Don't crash on small buffers.
-rw-r--r--ChangeLog5
-rw-r--r--ext/faad/gstfaad.c17
2 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c9c97ea..c4a52813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-16 Wim Taymans <wim@fluendo.com>
+
+ * ext/faad/gstfaad.c: (gst_faad_setcaps), (gst_faad_sync):
+ Don't crash on small buffers.
+
2006-07-15 Stefan Kost <ensonic@users.sf.net>
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_sink_activate):
diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c
index f7a06ece..dda21e95 100644
--- a/ext/faad/gstfaad.c
+++ b/ext/faad/gstfaad.c
@@ -299,10 +299,8 @@ gst_faad_setcaps (GstPad * pad, GstCaps * caps)
/* someone forgot that char can be unsigned when writing the API */
if ((gint8) faacDecInit2 (faad->handle,
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), &samplerate,
- &channels) < 0) {
- GST_DEBUG ("faacDecInit2() failed");
- return FALSE;
- }
+ &channels) < 0)
+ goto init_failed;
GST_DEBUG_OBJECT (faad, "channels=%u, rate=%u", channels, samplerate);
@@ -351,6 +349,13 @@ gst_faad_setcaps (GstPad * pad, GstCaps * caps)
gst_faad_send_tags (faad);
return TRUE;
+
+ /* ERRORS */
+init_failed:
+ {
+ GST_DEBUG_OBJECT (faad, "faacDecInit2() failed");
+ return FALSE;
+ }
}
@@ -1033,6 +1038,10 @@ gst_faad_sync (GstBuffer * buf, guint * off)
GST_DEBUG ("Finding syncpoint");
+ /* check for too small a buffer */
+ if (size < 3)
+ return FALSE;
+
/* FIXME: for no-sync, we go over the same data for every new buffer.
* We should save the information somewhere. */
for (n = 0; n < size - 3; n++) {