Commit 9bb91c4b26 for ffmpeg
commit 9bb91c4b26b4905415f61cca7cacd68c1a9e6072
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Wed Nov 11 15:22:27 2026 +0100
avcodec/huffyuvenc: require all luma rows the median predictor reads
Fixes: out of array read
Fixes: dx18scXFJJxI
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25573
Out of array read Replicated through UnModified FFmpeg with ASAN
Out of array read Replicated through API with ASAN
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 0719557667..d18c835c6b 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -372,7 +372,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (s->predictor == MEDIAN && s->version <= 2 &&
(avctx->width < 4 ||
- AV_CEIL_RSHIFT(avctx->height, s->chroma_v_shift) < 2 + s->interlaced)) {
+ avctx->height < (2 + s->interlaced) << s->chroma_v_shift)) {
av_log(avctx, AV_LOG_ERROR, "Frame too small for the median predictor\n");
return AVERROR(EINVAL);
}