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

Git pushed a commit to branch release/9.1
in repository ffmpeg.

commit 0be74c0eabff2b20ecef8e44ccf9319dd07046b4
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Sat Nov 14 01:57:50 2026 +0100
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Thu Nov 19 14:55:53 2026 +0100

    avfilter/vf_tmidequalizer: clip high bit depth samples to the histogram
    
    Fixes: out of array access
    Fixes: 1xO0YjckaN26
    Fixes: AISLE-2026-0166-00146
    
    Found-by: Joshua Rogers (AISLE)
    
    Out of array access Replicated through UnModified FFmpeg with ASAN
    
    (cherry picked from commit 1e1e424bd8d7a50a8213da1e95a92f524e9b801d)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_tmidequalizer.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_tmidequalizer.c b/libavfilter/vf_tmidequalizer.c
index 102d7c244f..9bdbcc40da 100644
--- a/libavfilter/vf_tmidequalizer.c
+++ b/libavfilter/vf_tmidequalizer.c
@@ -52,7 +52,8 @@ typedef struct TMidEqualizerContext {
                               int w, int h, float *histogram, size_t hsize);
     void (*apply_contrast_change)(const uint8_t *src, ptrdiff_t src_linesize,
                                   uint8_t *dst, ptrdiff_t dst_linesize,
-                                  int w, int h, float *change, float *orig);
+                                  int w, int h, float *change, float *orig,
+                                  size_t hsize);
 } TMidEqualizerContext;
 
 #define OFFSET(x) offsetof(TMidEqualizerContext, x)
@@ -135,7 +136,8 @@ static void compute_contrast_function(const float *const 
histograms[256],
 
 static void apply_contrast_change8(const uint8_t *src, ptrdiff_t src_linesize,
                                    uint8_t *dst, ptrdiff_t dst_linesize,
-                                   int w, int h, float *change, float *orig)
+                                   int w, int h, float *change, float *orig,
+                                   size_t hsize)
 {
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
@@ -148,14 +150,15 @@ static void apply_contrast_change8(const uint8_t *src, 
ptrdiff_t src_linesize,
 
 static void apply_contrast_change16(const uint8_t *ssrc, ptrdiff_t 
src_linesize,
                                     uint8_t *ddst, ptrdiff_t dst_linesize,
-                                    int w, int h, float *change, float *orig)
+                                    int w, int h, float *change, float *orig,
+                                    size_t hsize)
 {
     const uint16_t *src = (const uint16_t *)ssrc;
     uint16_t *dst = (uint16_t *)ddst;
 
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
-            dst[x] = lrintf(change[src[x]]);
+            dst[x] = lrintf(change[FFMIN(src[x], hsize - 1)]);
 
         dst += dst_linesize / 2;
         src += src_linesize / 2;
@@ -271,7 +274,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             s->apply_contrast_change(in->data[p], in->linesize[p],
                                      out->data[p], out->linesize[p],
                                      s->plane_width[p], s->plane_height[p],
-                                     s->change[p], s->histogram[p][idx]);
+                                     s->change[p], s->histogram[p][idx],
+                                     s->histogram_size);
         }
     }
 
@@ -309,7 +313,7 @@ static void compute_histogram16(const uint8_t *ssrc, 
ptrdiff_t linesize,
 
     for (int y = 0; y < h; y++) {
         for (int x = 0; x < w; x++)
-            histogram[src[x]] += 1;
+            histogram[FFMIN(src[x], hsize - 1)] += 1;
         src += linesize / 2;
     }
 

-- 
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