Commit 53f88ba1cf for ffmpeg

commit 53f88ba1cfde8d8357a9ce405e4be2709df0280c
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Wed Sep 9 04:10:43 2026 +0200

    swscale/utils: do not let a filter wider than the source read past the line

    Fixes: heap-buffer-overflow read in hScale8To15_c()
    Fixes: sws-filter-oob-handcrafted / gen3.py (fairy/pr21601-repro)
    Found-by: Forgejo Fairy while reviewing PR #21601

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 678e53f405..0cd80ede65 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -512,7 +512,6 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
         ret = RETCODE_USE_CASCADE;
         goto fail;
     }
-    *outFilterSize = filterSize;

     if (flags & SWS_PRINT_INFO)
         av_log(NULL, AV_LOG_VERBOSE,
@@ -577,6 +576,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
         }
     }

+    *outFilterSize = FFMIN(filterSize, FFALIGN(srcW, filterAlign));
+
     // Note the +1 is for the MMX scaler which reads over the end
     /* align at 16 for AltiVec (needed by hScale_altivec_real) */
     *outFilter = av_calloc(dstW + 3, *outFilterSize * sizeof(**outFilter));