aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-09-20 10:25:05 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-31 19:51:55 +0100
commit28aafef295014edf6f231de51a371ddbe0acb424 (patch)
tree7e7cb5200fb5c7a39d0bd05b59678a24a8cbe579
parent75cd59ec213c9282acd5271d0cbacc4505ae7a3b (diff)
downloadffmpeg-28aafef295014edf6f231de51a371ddbe0acb424.tar.gz
avcodec/utils: Check channels fully earlier
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 83f2555e5ff571cbf5c226a920602e91228039ab) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 729c10a8ed..c48ada599a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -678,8 +678,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (av_codec_is_decoder(codec))
av_freep(&avctx->subtitle_header);
- if (avctx->channels > FF_SANE_NB_CHANNELS) {
- av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->channels);
+ if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels);
ret = AVERROR(EINVAL);
goto free_and_end;
}