Commit 0b95476bd3 for ffmpeg
commit 0b95476bd3b1fcf8ea9d1526d1fd4d1b63bae6a9
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Wed Nov 18 05:24:59 2026 +0100
avcodec/cbs_h265: bound the number of decoding units when the SPS has no picture size
Fixes: out of array write
Fixes: UgwoO3TwWfCu
Fixes: ANT-2026-ZR7AO0XN
Regression since: 8864fd0aec
Found-by: Anthropic's OSS Scanner
Out of array write Replicated through UnModified FFmpeg with ASAN
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index 1e03bdf63e..cf4758fd1e 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1993,7 +1993,7 @@ SEI_FUNC(sei_pic_timing, (CodedBitstreamContext *ctx, RWContext *rw,
// than HEVC_MAX_SLICE_SEGMENTS slice segments (A.4.2), which is also
// the size of the arrays indexed by it.
ue(num_decoding_units_minus1, 0,
- FFMIN(pic_width_in_ctbs_y * pic_height_in_ctbs_y, HEVC_MAX_SLICE_SEGMENTS) - 1);
+ FFMIN(pic_width_in_ctbs_y * pic_height_in_ctbs_y - 1, HEVC_MAX_SLICE_SEGMENTS - 1));
flag(du_common_cpb_removal_delay_flag);
length = hrd->du_cpb_removal_delay_increment_length_minus1 + 1;