avfilter/f_perms: free the input frame when it cannot be made writable or cloned

Fixes: 1MIkYBeZ4sTX
Fixes: memleak
Memory leak Replicated through Modified FFmpeg with LSan
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24765
This commit is contained in:
Michael Niedermayer authored and michaelni committed 2026-10-20 20:41:50 +00:00
1 parent 88cd68c8fd
commit f90f210d31
1 file changed
+6 -2
+6 -2
View File
@@ -97,13 +97,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
in_perm == out_perm ? " (no-op)" : "");
if (in_perm == RO && out_perm == RW) {
if ((ret = ff_inlink_make_frame_writable(inlink, &frame)) < 0)
if ((ret = ff_inlink_make_frame_writable(inlink, &frame)) < 0) {
av_frame_free(&frame);
return ret;
}
out = frame;
} else if (in_perm == RW && out_perm == RO) {
out = av_frame_clone(frame);
if (!out)
if (!out) {
av_frame_free(&frame);
return AVERROR(ENOMEM);
}
}
ret = ff_filter_frame(ctx->outputs[0], out);