diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index c3174ce6ef..eb051eba54 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -267,6 +267,11 @@ static int escape124_decode_frame(AVCodecContext *avctx, cb_size = s->num_superblocks << cb_depth; } } + if (s->num_superblocks >= INT_MAX >> cb_depth) { + av_log(avctx, AV_LOG_ERROR, "Depth or num_superblocks are too large\n"); + return AVERROR_INVALIDDATA; + } + av_freep(&s->codebooks[i].blocks); s->codebooks[i] = unpack_codebook(&gb, cb_depth, cb_size); if (!s->codebooks[i].blocks)