diff --git a/libavcodec/exr.c b/libavcodec/exr.c index a62a4c8a6f..329db66149 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -537,7 +537,7 @@ static int huf_decode(const uint64_t *hcode, const HufDec *hdecod, while (lc > 0) { const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK]; - if (pl.len) { + if (pl.len && lc >= pl.len) { lc -= pl.len; get_code(pl.lit, rlc, c, lc, gb, out, oe, outb); } else {