X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fescape124.c;h=cffd3e12b1ad755408db93dbd0cd2f84661f5d09;hb=c0ee4e0ac2c46bb4904ceec12b7dfa480517e7bf;hp=eb051eba54a5a006aafc86f089b3b940cf2db096;hpb=77eba7bd99355fc37a2bfc9d0224218f4022762c;p=ffmpeg diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index eb051eba54a..cffd3e12b1a 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -221,7 +221,11 @@ static int escape124_decode_frame(AVCodecContext *avctx, // This call also guards the potential depth reads for the // codebook unpacking. - if (get_bits_left(&gb) < 64) + // Check if the amount we will read minimally is available on input. + // The 64 represent the immediately next 2 frame_* elements read, the 23/4320 + // represent a lower bound of the space needed for skipped superblocks. Non + // skipped SBs need more space. + if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320) return -1; frame_flags = get_bits_long(&gb, 32);