PR #25473 opened by Kilian (lusoris)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25473
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25473.patch

This patch addresses GCC 14.4.0 -Warray-bounds diagnostics in the recursive 
search in libavfilter/vf_find_rect.c. The filter is GPL-only.

What the patch does:

- `avfilter/vf_find_rect: assert the mipmap search pass bounds`: adds an 
always-on assertion that the pass is below MAX_MIPMAPS on entry to the 
recursive search.

Behaviour change: an out-of-range pass triggers an always-on assertion; 
searches within the supported range are unchanged.

Base: FFmpeg master 46f23be8b1.

Testing:

- GCC 14.4.0 (`--enable-gpl --enable-vulkan`) and GCC 16.2.1 (`--enable-gpl 
--enable-vulkan --enable-vaapi --enable-libdrm --enable-nvenc`), targets all, 
alltools, examples, testprogs and checkasm: master 46f23be8b1 shows, with GCC 
14.4.0, 2 -Warray-bounds warnings in libavfilter/vf_find_rect.c, and with GCC 
16.2.1, no warning; with this patch there are none and no new ones.
- FATE has no test for vf_find_rect.

Split out of #25111 so that each part reaches the reviewers for its area.



>From 25e2bc884bf450db1990e95d6b86c725e4a3fc73 Mon Sep 17 00:00:00 2001
From: lusoris <[email protected]>
Date: Thu, 15 Oct 2026 22:06:36 +0200
Subject: [PATCH] avfilter/vf_find_rect: assert the mipmap search pass bounds

GCC 14.4.0 reports -Warray-bounds in the recursive search (the filter
is only built with --enable-gpl). The pass number selects a mipmap
level, and the compiler cannot see that the recursion stops before
MAX_MIPMAPS. Assert that the pass is below MAX_MIPMAPS on entry.
Searches within that range are unchanged.

Signed-off-by: lusoris <[email protected]>
---
 libavfilter/vf_find_rect.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index 88dfecbe222..98e251e64bd 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -22,6 +22,7 @@
  * @todo switch to dualinput
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/opt.h"
 
 #include "filters.h"
@@ -153,6 +154,8 @@ static float search(FOCContext *foc, int pass, int maxpass, 
int xmin, int xmax,
 {
     int x, y;
 
+    av_assert0((unsigned)pass < MAX_MIPMAPS);
+
     if (pass + 1 <= maxpass) {
         int sub_x, sub_y;
         search(foc, pass+1, maxpass, xmin>>1, (xmax+1)>>1, ymin>>1, 
(ymax+1)>>1, &sub_x, &sub_y, 2.0);
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to