apedec: assert that s->samples is not negative before trying to decode
authorJustin Ruggles <justin.ruggles@gmail.com>
Tue, 11 Oct 2011 18:38:21 +0000 (14:38 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Fri, 28 Oct 2011 15:47:29 +0000 (11:47 -0400)
libavcodec/apedec.c

index 8b1af80..e906903 100644 (file)
@@ -26,6 +26,7 @@
 #include "get_bits.h"
 #include "bytestream.h"
 #include "libavutil/audioconvert.h"
+#include "libavutil/avassert.h"
 
 /**
  * @file
@@ -834,6 +835,10 @@ static int ape_decode_frame(AVCodecContext *avctx,
         return AVERROR(EINVAL);
     }
 
+    /* this should never be negative, but bad things will happen if it is, so
+       check it just to make sure. */
+    av_assert0(s->samples >= 0);
+
     if(!s->samples){
         uint32_t offset;
         void *tmp_data;