Commit d06847c706 for ffmpeg
commit d06847c706ce1559c83cadba2fffbb4dd5632293
Author: Qingzheng Li <s@qwqlog.com>
Date: Thu Aug 6 01:22:57 2026 +0800
avfilter/swaprect: free the input frame when an expression fails
Route expression failures through a common cleanup path,
since filter_frame() owns the input frame until it is forwarded.
Fixes: memory leak
Signed-off-by: Qingzheng Li <s@qwqlog.com>
diff --git a/libavfilter/vf_swaprect.c b/libavfilter/vf_swaprect.c
index fe007ee5e7..c56cf6bca0 100644
--- a/libavfilter/vf_swaprect.c
+++ b/libavfilter/vf_swaprect.c
@@ -101,42 +101,42 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
ret = av_expr_parse_and_eval(&dh, s->h,
var_names, &var_values[0],
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
ret = av_expr_parse_and_eval(&dx1, s->x1,
var_names, &var_values[0],
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
ret = av_expr_parse_and_eval(&dy1, s->y1,
var_names, &var_values[0],
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
ret = av_expr_parse_and_eval(&dx2, s->x2,
var_names, &var_values[0],
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
ret = av_expr_parse_and_eval(&dy2, s->y2,
var_names, &var_values[0],
NULL, NULL, NULL, NULL,
0, 0, ctx);
if (ret < 0)
- return ret;
+ goto fail;
w = dw; h = dh; x1[0] = dx1; y1[0] = dy1; x2[0] = dx2; y2[0] = dy2;
@@ -194,6 +194,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
return ff_filter_frame(outlink, in);
+
+fail:
+ av_frame_free(&in);
+ return ret;
}
static int config_input(AVFilterLink *inlink)