[FFmpeg-cvslog] avfilter/vf_zscale: fix leaks in fast/bypass path

Paul B Mahol git at videolan.org
Fri Mar 4 15:07:06 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Mar  4 14:05:55 2022 +0100| [779ae049b26ad0ea878bfc4a3a2326308b8f6b13] | committer: Paul B Mahol

avfilter/vf_zscale: fix leaks in fast/bypass path

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=779ae049b26ad0ea878bfc4a3a2326308b8f6b13
---

 libavfilter/vf_zscale.c | 20 +++++++++-----------
 1 file 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);
     }



More information about the ffmpeg-cvslog mailing list