This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit ca5c10f18806808f12e6669890cf17d990225c3c
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Wed Sep 23 23:42:03 2026 +0200
Commit:     Timo Rothenpieler <[email protected]>
CommitDate: Fri Sep 25 01:08:29 2026 +0000

    avfilter/vf_thumbnail_cuda: clamp the 16-bit histogram bin to 255
    
    Fixes: out of array write
    Fixes: KsEohQi9YQw8
    Found-by: zhang xingxing
    Suggested-by: zhang xingxing
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_thumbnail_cuda.cu | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_thumbnail_cuda.cu b/libavfilter/vf_thumbnail_cuda.cu
index d4d4d791f6..350f4da6be 100644
--- a/libavfilter/vf_thumbnail_cuda.cu
+++ b/libavfilter/vf_thumbnail_cuda.cu
@@ -56,8 +56,8 @@ __global__ void Thumbnail_ushort(cudaTextureObject_t 
ushort_tex,
 
     if (y < src_height && x < src_width)
     {
-        unsigned short pixel = (tex2D<unsigned short>(ushort_tex, x, y) + 128) 
>> 8;
-        atomicAdd(&histogram[pixel], 1);
+        int pixel = (tex2D<unsigned short>(ushort_tex, x, y) + 128) >> 8;
+        atomicAdd(&histogram[min(pixel, 255)], 1);
     }
 }
 
@@ -70,8 +70,8 @@ __global__ void Thumbnail_ushort2(cudaTextureObject_t 
ushort2_tex,
     if (y < src_height && x < src_width)
     {
         ushort2 pixel = tex2D<ushort2>(ushort2_tex, x, y);
-        atomicAdd(&histogram[(pixel.x + 128) >> 8], 1);
-        atomicAdd(&histogram[256 + ((pixel.y + 128) >> 8)], 1);
+        atomicAdd(&histogram[min((pixel.x + 128) >> 8, 255)], 1);
+        atomicAdd(&histogram[256 + min((pixel.y + 128) >> 8, 255)], 1);
     }
 }
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to