PR #24623 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24623
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24623.patch

Found-by: zhang xingxing <[email protected]>
Suggested-by: zhang xingxing <[email protected]>
Fixes: out of array read
Fixes: VoiiaDYyhdfz



>From 5f442e9da2f750a37b1a4ff3dd4649d8760ec06c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 22 Sep 2026 00:30:20 +0200
Subject: [PATCH] avfilter/vf_cropdetect: scan the edge map with a one byte
 pixel step

Found-by: zhang xingxing <[email protected]>
Suggested-by: zhang xingxing <[email protected]>
Fixes: out of array read
Fixes: VoiiaDYyhdfz
---
 libavfilter/vf_cropdetect.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 7c14cd117e..e9c12e5479 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -359,7 +359,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 
 #define FIND_EDGE(DST, FROM, NOEND, INC, STEP0, STEP1, LEN)             \
     for (last_y = y = FROM; NOEND; y = y INC) {                         \
-        if (checkline_edge(ctx, tmpbuf + STEP0 * y, STEP1, LEN, bpp)) { \
+        if (checkline_edge(ctx, tmpbuf + STEP0 * y, STEP1, LEN, 1)) {   \
             if (last_y INC == y) {                                      \
                 DST = y;                                                \
                 break;                                                  \
@@ -371,10 +371,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
         DST = y -(INC);                                                 \
     }
 
-                FIND_EDGE(s->y1, s->y1, y >=  0, -1, inw, bpp, scan_w);
-                FIND_EDGE(s->y2, s->y2, y < inh, +1, inw, bpp, scan_w);
-                FIND_EDGE(s->x1, s->x1, y >=  0, -1, bpp, inw, scan_h);
-                FIND_EDGE(s->x2, s->x2, y < inw, +1, bpp, inw, scan_h);
+                FIND_EDGE(s->y1, s->y1, y >=  0, -1, inw, 1, scan_w);
+                FIND_EDGE(s->y2, s->y2, y < inh, +1, inw, 1, scan_w);
+                FIND_EDGE(s->x1, s->x1, y >=  0, -1, 1, inw, scan_h);
+                FIND_EDGE(s->x2, s->x2, y < inw, +1, 1, inw, scan_h);
 
                 // queue bboxes
                 bboff = (s->frame_nb - 1) % s->window_size;
-- 
2.52.0

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

Reply via email to