Commit 03ec575ff3 for ffmpeg

commit 03ec575ff3f6240e9fb4b39e1057f4ac251f7161
Author: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date:   Mon Nov 23 19:27:21 2026 +0100

    avcodec/vc1,vc1dec: Pad blocks for LASX, MSA

    The 4x4 and 4x8 LASX and 4x8 MSA inverse transform
    DSP functions overread the input block (for the offsetted
    last subblock). This has been found by Forgejo_Fairy
    in [1] and confirmed with Valgrind by making the corresponding
    C versions read as much data as the LASX and MSA DSP functions
    and checking with Valgrind for overreads.

    Workaround this by padding the blocks for said arches.
    Both VC1Context.blocks and VC1Context.block need to be padded.

    (Notice that before 20ee12c677c6f58afbae643f039ba06e7d6f070a,
    the predecessor of VC1Context.blocks was padded, albeit
    unintentionally.)

    [1]: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26295#issuecomment-90518

    Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 006cefd58e..d3b9f7c103 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -403,7 +403,9 @@ typedef struct VC1Context{
     int parse_only;              ///< Context is used within parser
     int resync_marker;           ///< could this stream contain resync markers

-    DECLARE_ALIGNED_32(int16_t, blocks)[6][64];
+    // FIXME: The 4x4 and 4x8 LASX and 4x8 MSA inverse transform DSP functions
+    // overread the (offsetted) input block, hence the padding with another block.
+    DECLARE_ALIGNED_32(int16_t, blocks)[6 + (HAVE_LASX || HAVE_MSA)][64];
 } VC1Context;

 /**
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index a4d465dd0b..0336c1848e 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -374,7 +374,10 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
         return AVERROR(ENOMEM);

     v->n_allocated_blks = s->mb_width + 2;
-    v->block            = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
+    // FIXME: The 4x4 and 4x8 LASX and 4x8 MSA inverse transform DSP functions
+    // overread the (offsetted) input block, hence the padding.
+    v->block            = av_malloc(sizeof(*v->block) * v->n_allocated_blks +
+                                    4 * sizeof(***v->block) * (HAVE_LASX || HAVE_MSA));
     v->cbp_base         = av_malloc(sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
     if (!v->block || !v->cbp_base)
         return AVERROR(ENOMEM);