Commit dd1b4e4ba5 for ffmpeg

commit dd1b4e4ba5c3280638fed06a88bf25690564170b
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Sat Nov 14 05:22:02 2026 +0100

    avfilter/vf_scale: reject commands using ref variables without a ref input

    Fixes: out of array read
    Fixes: qNXODI0YyLo1
    Fixes: AISLE-2026-0166-00236

    Found-by: Joshua Rogers (AISLE)
    The rejected expression case was found during triage of the security report

    Out of array read Replicated through UnModified FFmpeg with ASAN

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 6c1bf88879..6f0840801a 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -257,7 +257,7 @@ static int check_exprs(AVFilterContext *ctx)
 static int scale_parse_expr(AVFilterContext *ctx, char *str_expr, AVExpr **pexpr_ptr, const char *var, const char *args)
 {
     ScaleContext *scale = ctx->priv;
-    int ret, is_inited = 0;
+    int ret, is_inited = 0, old_uses_ref = scale->uses_ref;
     char *old_str_expr = NULL;
     AVExpr *old_pexpr = NULL;

@@ -285,6 +285,12 @@ static int scale_parse_expr(AVFilterContext *ctx, char *str_expr, AVExpr **pexpr
     if (ret < 0)
         goto revert;

+    if (is_inited && scale->uses_ref && ctx->nb_inputs == 1) {
+        av_log(ctx, AV_LOG_ERROR, "Expressions with ref variables need the ref input, a command cannot add it.\n");
+        ret = AVERROR(EINVAL);
+        goto revert;
+    }
+
     if (is_inited && (ret = config_props(ctx->outputs[0])) < 0)
         goto revert;

@@ -295,6 +301,7 @@ static int scale_parse_expr(AVFilterContext *ctx, char *str_expr, AVExpr **pexpr
     return 0;

 revert:
+    scale->uses_ref = old_uses_ref;
     av_expr_free(*pexpr_ptr);
     *pexpr_ptr = NULL;
     if (old_str_expr) {