summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-03-18 00:11:28 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2022-03-18 12:31:32 +0100
commit31916d3d9fc61bab50ccbcc2d58bf7e7efb6c8a0 (patch)
tree92ee5e78d31cbaba082a90999613ce1e7f9f9d37 /libavcodec
parentb59ea948cdcb8422964595c32076312756550f17 (diff)
avcodec/alsdec: Set channels from data after data is set
Fixes: out of array write Fixes: 45624/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-6473487382872064 Fixes: 45626/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-4874997192065024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/alsdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 822cf211b0..73af829178 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1986,7 +1986,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
unsigned int c;
unsigned int channel_size;
int num_buffers, ret;
- int channels = avctx->ch_layout.nb_channels;
+ int channels;
ALSDecContext *ctx = avctx->priv_data;
ALSSpecificConfig *sconf = &ctx->sconf;
ctx->avctx = avctx;
@@ -2000,6 +2000,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
return ret;
}
+ channels = avctx->ch_layout.nb_channels;
if ((ret = check_specific_config(ctx)) < 0) {
return ret;