[FFmpeg-cvslog] avfilter/vf_vpp_qsv: Fix leak of AVFilterFormats on error

Andreas Rheinhardt git at videolan.org
Mon Aug 24 02:09:39 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Aug  7 05:54:34 2020 +0200| [c4beb0783bd2470edbcc8da9e264c7fe1c10d7cc] | committer: Andreas Rheinhardt

avfilter/vf_vpp_qsv: Fix leak of AVFilterFormats on error

The vpp_qsv's query_formats function allocated two AVFilterFormats,
before storing them permanently. If storing the first of them fails,
the function simply returns and the second leaks. This has been fixed by
only allocating the second AVFilterFormats structure after the first one
has been successfully stored.

Fixes Coverity issue #1422231.

Reviewed-by: Nicolas George <george at nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavfilter/vf_vpp_qsv.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 3194295f5f..12023af2d7 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -489,7 +489,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
 static int query_formats(AVFilterContext *ctx)
 {
     int ret;
-    AVFilterFormats *in_fmts, *out_fmts;
     static const enum AVPixelFormat in_pix_fmts[] = {
         AV_PIX_FMT_YUV420P,
         AV_PIX_FMT_NV12,
@@ -505,16 +504,12 @@ static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_NONE
     };
 
-    in_fmts  = ff_make_format_list(in_pix_fmts);
-    out_fmts = ff_make_format_list(out_pix_fmts);
-    ret = ff_formats_ref(in_fmts, &ctx->inputs[0]->out_formats);
+    ret = ff_formats_ref(ff_make_format_list(in_pix_fmts),
+                         &ctx->inputs[0]->out_formats);
     if (ret < 0)
         return ret;
-    ret = ff_formats_ref(out_fmts, &ctx->outputs[0]->in_formats);
-    if (ret < 0)
-        return ret;
-
-    return 0;
+    return ff_formats_ref(ff_make_format_list(out_pix_fmts),
+                          &ctx->outputs[0]->in_formats);
 }
 
 static av_cold void vpp_uninit(AVFilterContext *ctx)



More information about the ffmpeg-cvslog mailing list