[FFmpeg-cvslog] avcodec/h261enc: Don't use (size_t)-1

Andreas Rheinhardt git at videolan.org
Thu Mar 20 09:10:08 EET 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Mar 17 09:53:42 2025 +0100| [fbcc943b22534517670d287f35eebe40896f771f] | committer: Andreas Rheinhardt

avcodec/h261enc: Don't use (size_t)-1

Fixes "runtime error: addition of unsigned offset to 0x765a09523a90
overflowed to 0x765a09523a8e". This fixes all H.261 tests when run
under UBsan.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fbcc943b22534517670d287f35eebe40896f771f
---

 libavcodec/h261enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 36436ee60f..5e6d5d1f9c 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -337,7 +337,7 @@ static av_cold void h261_encode_init_static(void)
         uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 - level)] = len + 2;
     }
 
-    for (size_t i = 1;; i++) {
+    for (ptrdiff_t i = 1;; i++) {
         // sign-one MV codes; diff -16..-1, 16..31
         mv_codes[32 - i][0] = mv_codes[-i][0] = (ff_h261_mv_tab[i][0] << 1) | 1 /* sign */;
         mv_codes[32 - i][1] = mv_codes[-i][1] = ff_h261_mv_tab[i][1] + 1;



More information about the ffmpeg-cvslog mailing list