[03/18] mace: Make sure that the channel count is set to a valid value

Message ID 1379358389-64839-3-git-send-email-martin@martin.st
State Committed
Commit e1f3847f860a1094a46be4c5f10db8df616c3135
Headers show

Commit Message

Martin Storsjö Sept. 16, 2013, 7:06 p.m.
Also return a proper error code.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavcodec/mace.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Luca Barbato Sept. 16, 2013, 9:36 p.m. | #1
On 16/09/13 21:06, Martin Storsjö wrote:
> Also return a proper error code.
> 
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavcodec/mace.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Ok.

Patch

diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index 559dcee..76118e8 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -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;