diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 9a8d6cc276..16c6713cd4 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -191,13 +191,6 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - av_assert0(avctx->ch_layout.nb_channels >= 0); - if (avctx->ch_layout.nb_channels > WMALL_MAX_CHANNELS) { - avpriv_request_sample(avctx, - "More than " AV_STRINGIFY(WMALL_MAX_CHANNELS) " channels"); - return AVERROR_PATCHWELCOME; - } - if (avctx->extradata_size >= 18) { s->decode_flags = AV_RL16(edata_ptr + 14); channel_mask = AV_RL32(edata_ptr + 2); @@ -226,6 +219,12 @@ static av_cold int decode_init(AVCodecContext *avctx) av_channel_layout_uninit(&avctx->ch_layout); av_channel_layout_from_mask(&avctx->ch_layout, channel_mask); } + av_assert0(avctx->ch_layout.nb_channels >= 0); + if (avctx->ch_layout.nb_channels > WMALL_MAX_CHANNELS) { + avpriv_request_sample(avctx, + "More than " AV_STRINGIFY(WMALL_MAX_CHANNELS) " channels"); + return AVERROR_PATCHWELCOME; + } s->num_channels = avctx->ch_layout.nb_channels;