Commit bc74cf91f0 for ffmpeg
commit bc74cf91f04adc479e6f101b75b56f31af42268a
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sun Oct 11 07:31:13 2026 +0200
avutil/imgutils: compute the line size of bitstream formats without overflow
Fixes: signed integer overflow
Fixes: P0BVJKDC5JLx
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24756
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 8ff8a6be41..1aa6ab0cd3 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -69,7 +69,7 @@ int image_get_linesize(int width, int plane,
linesize = max_step * shifted_w;
if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)
- linesize = (linesize + 7) >> 3;
+ linesize = (linesize >> 3) + !!(linesize & 7);
return linesize;
}