summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-03-04 14:05:55 +0100
committerPaul B Mahol <onemda@gmail.com>2022-03-04 14:07:20 +0100
commit779ae049b26ad0ea878bfc4a3a2326308b8f6b13 (patch)
treee1fd92a24ce7efcf9e8055e45698132902f9bc36
parent806109841810da60e41499018090401529040fd8 (diff)
avfilter/vf_zscale: fix leaks in fast/bypass path
-rw-r--r--libavfilter/vf_zscale.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 6e94fc8c82..afbe7d9dcd 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -760,15 +760,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
AVFrame *out = NULL;
ThreadData td;
- if (!(out = ff_get_video_buffer(outlink, outlink->w, outlink->h))) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
- av_frame_copy_props(out, in);
- out->width = outlink->w;
- out->height = outlink->h;
-
//we need to use this filter if something is different for an input and output only
//otherwise - just copy the input frame to the output
if ((link->w != outlink->w) ||
@@ -783,6 +774,14 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
(s->src_format.pixel_type !=s->dst_format.pixel_type) ||
(s->src_format.transfer_characteristics !=s->dst_format.transfer_characteristics)
){
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+ if (!out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ av_frame_copy_props(out, in);
+
if ((ret = realign_frame(desc, &in)) < 0)
goto fail;
@@ -879,8 +878,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
}
}
- }
- else {
+ } else {
/*no need for any filtering */
return ff_filter_frame(outlink, in);
}