ttadec: check channel count as read from extradata.
authorShitiz Garg <mail@dragooon.net>
Sat, 10 Dec 2011 19:40:57 +0000 (01:10 +0530)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sat, 10 Dec 2011 19:54:19 +0000 (14:54 -0500)
fixes floating-point exception due to channels being set to 0.
fixes Bug 128.

Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
libavcodec/tta.c

index 6b76f52..c8d58fd 100644 (file)
@@ -221,6 +221,11 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
         s->data_length = get_bits_long(&s->gb, 32);
         skip_bits(&s->gb, 32); // CRC32 of header
 
+        if (s->channels == 0) {
+            av_log(s->avctx, AV_LOG_ERROR, "Invalid number of channels\n");
+            return AVERROR_INVALIDDATA;
+        }
+
         switch(s->bps) {
         case 2:
             avctx->sample_fmt = AV_SAMPLE_FMT_S16;