diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c index 348d2de06b..19f3e110f4 100644 --- a/libavcodec/lzw.c +++ b/libavcodec/lzw.c @@ -190,6 +190,10 @@ int ff_lzw_decode(LZWState *p, uint8_t *buf, int len){ if ((--l) == 0) goto the_end; } + if (s->ebuf < s->pbuf) { + av_log(0, AV_LOG_ERROR, "lzw overread\n"); + goto the_end; + } c = lzw_get_code(s); if (c == s->end_code) { break;