Commit 3dd257f99b for ffmpeg

commit 3dd257f99b5cdc1bf38e1cadff1e34ec559c7b7c
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Sat Nov 14 05:14:09 2026 +0100

    avfilter/af_dynaudnorm: resize the gain histories by the change of the filter size

    Fixes: out of array access (memmove with negative size)
    Fixes: out of array write
    Fixes: ArUvqAYbevNM
    Fixes: AISLE-2026-0166-00680

    Found-by: Joshua Rogers (AISLE)
    The out of array write was found during triage of the security report

    Out of array access Replicated through UnModified FFmpeg with ASAN
    Out of array write Replicated through UnModified FFmpeg with ASAN
    no further issues found with 3000 iterations of a random gausssize command sequence generator

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 1af6a3ed9f..e00405995c 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -261,14 +261,14 @@ static void cqueue_resize(cqueue *q, int new_size)
     av_assert2(q->max_size >= new_size);
     av_assert2(MIN_FILTER_SIZE <= new_size);

-    if (new_size > q->nb_elements) {
-        const int side = (new_size - q->nb_elements) / 2;
+    if (!cqueue_empty(q) && new_size > q->size) {
+        const int side = (new_size - q->size) / 2;

         memmove(q->elements + side, q->elements, sizeof(double) * q->nb_elements);
         for (int i = 0; i < side; i++)
             q->elements[i] = q->elements[side];
-        q->nb_elements = new_size - 1 - side;
-    } else {
+        q->nb_elements += side;
+    } else if (!cqueue_empty(q)) {
         int count = (q->size - new_size + 1) / 2;

         while (count-- > 0)