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

Git pushed a commit to branch master
in repository ffmpeg.

commit 82538d0846a469fbe2d99bfd2c8a6b6201c1aa2e
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Thu Nov 12 05:17:25 2026 +0100
Commit:     michaelni <[email protected]>
CommitDate: Wed Nov 18 23:19:07 2026 +0000

    swscale/output: do not store past an odd width in the 16 bit RGB C functions
    
    Fixes: out of array write
    Fixes: bKTdZBAokzK8
    Fixes: sws_565_exact.c
    Fixes: sws_full_sweep.c
    Out of array write Replicated through API with Valgrind
    
    Found-by: Kim Jeongsu with StealthMole
---
 libswscale/output.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index cf3cea8955..0cdb833fdf 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1671,7 +1671,7 @@ YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbxf32le_full, 
AV_PIX_FMT_RGBAF32, LE, 0
  * correct RGB values into the destination buffer.
  */
 static av_always_inline void
-yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
+yuv2rgb_write(uint8_t *_dest, int i, int dstW, int Y1, int Y2,
               unsigned A1, unsigned A2,
               const void *_r, const void *_g, const void *_b, int y,
               enum AVPixelFormat target, int hasAlpha)
@@ -1755,7 +1755,10 @@ yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
         }
 
         dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
-        dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
+        /* these formats have no full chroma interpolation and so are
+         * output in pairs for odd widths too */
+        if (i * 2 + 1 < dstW)
+            dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
     } else if (target == AV_PIX_FMT_X2RGB10 || target == AV_PIX_FMT_X2BGR10) {
         uint32_t *dest = (uint32_t *) _dest;
         const uint32_t *r = (const uint32_t *) _r;
@@ -1845,7 +1848,7 @@ yuv2rgb_X_c_template(SwsInternal *c, const int16_t 
*lumFilter,
         g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + 
YUVRGB_TABLE_HEADROOM]);
         b =  c->table_bU[U + YUVRGB_TABLE_HEADROOM];
 
-        yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
+        yuv2rgb_write(dest, i, dstW, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 
: 0,
                       r, g, b, y, target, hasAlpha);
     }
 }
@@ -1885,7 +1888,7 @@ yuv2rgb_2_c_template(SwsInternal *c, const int16_t 
*buf[2],
             A2 = av_clip_uint8(A2);
         }
 
-        yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
+        yuv2rgb_write(dest, i, dstW, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 
: 0,
                       r, g, b, y, target, hasAlpha);
     }
 }
@@ -1918,7 +1921,7 @@ yuv2rgb_1_c_template(SwsInternal *c, const int16_t *buf0,
                 A2 = av_clip_uint8(A2);
             }
 
-            yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 
0,
+            yuv2rgb_write(dest, i, dstW, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? 
A2 : 0,
                           r, g, b, y, target, hasAlpha);
         }
     } else {
@@ -1943,7 +1946,7 @@ yuv2rgb_1_c_template(SwsInternal *c, const int16_t *buf0,
                 A2 = av_clip_uint8(A2);
             }
 
-            yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 
0,
+            yuv2rgb_write(dest, i, dstW, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? 
A2 : 0,
                           r, g, b, y, target, hasAlpha);
         }
     }

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