mace: Make sure that the channel count is set to a valid value
authorMartin Storsjö <martin@martin.st>
Mon, 16 Sep 2013 12:19:52 +0000 (15:19 +0300)
committerMartin Storsjö <martin@martin.st>
Tue, 17 Sep 2013 08:21:46 +0000 (11:21 +0300)
Also return a proper error code.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
libavcodec/mace.c

index 559dcee..76118e8 100644 (file)
@@ -226,8 +226,8 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
 
 static av_cold int mace_decode_init(AVCodecContext * avctx)
 {
-    if (avctx->channels > 2)
-        return -1;
+    if (avctx->channels > 2 || avctx->channels < 1)
+        return AVERROR(EINVAL);
     avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
 
     return 0;