Commit 66b6ca270b for ffmpeg

commit 66b6ca270b33fd74367d7d371f6de16ec664446e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Sun Oct 11 07:31:13 2026 +0200

    avcodec/sunrast: expand only the bytes of a packed line that were decoded

    The 1 and 4 bit per pixel expansion read (w + 7 >> 3) * depth bytes per
    line while only (depth * w + 7) >> 3 were written, for 4 bits per pixel
    and widths that are not a multiple of 8 up to 3 uninitialized bytes per
    line were expanded into the padding of the line.

    Fixes: use of uninitialized memory
    Fixes: mGcNxX6EOTeJ
    Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24877
    Use of uninitialized memory Replicated through API with Valgrind

diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index 1cd51f4637..fcab3de3b5 100644
--- a/libavcodec/sunrast.c
+++ b/libavcodec/sunrast.c
@@ -199,7 +199,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p,
         uint8_t *ptr_free = ptr2;
         ptr = p->data[0];
         for (y=0; y<h; y++) {
-            for (x = 0; x < (w + 7 >> 3) * depth; x++) {
+            for (x = 0; x < len; x++) {
                 if (depth == 1) {
                     ptr[8*x]   = ptr2[x] >> 7;
                     ptr[8*x+1] = ptr2[x] >> 6 & 1;