diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 0f1f683e7e..09f2fca109 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -335,7 +335,10 @@ static int huf_unpack_enc_table(GetByteContext *gb, return ret; for (; im <= iM; im++) { - uint64_t l = freq[im] = get_bits(&gbit, 6); + uint64_t l; + if (get_bits_left(&gbit) < 6) + return AVERROR_INVALIDDATA; + l = freq[im] = get_bits(&gbit, 6); if (l == LONG_ZEROCODE_RUN) { int zerun = get_bits(&gbit, 8) + SHORTEST_LONG_RUN;