diff mbox

[FFmpeg-devel,V3] vf_hwupload: Add missing return value check

Message ID fbfa8e10-1e67-b2ca-727a-70c3a891fcee@gmail.com
State Accepted
Commit bf238a6a3ca92de686e0e103135c1336f33f685b
Headers show

Commit Message

Jun Zhao March 10, 2017, 1:23 a.m. UTC
V3: just remove noop ff_formats_unref() and add missing return value checks to suppress build warning.
From 67633ff014ee472a6494d792c8c8e057acc197c4 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Fri, 3 Mar 2017 09:25:53 +0800
Subject: [PATCH] vf_hwupload: Add missing return value check

Add missing return value checks to suppress build warning and
remove noop ff_formats_unref() calling.

Note: most filters using ff_formats_ref() didn't have a suitable
error handling, it's a potential memory leak issue.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
---
 libavfilter/vf_hwupload.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Mark Thompson March 12, 2017, 6:15 p.m. UTC | #1
On 10/03/17 01:23, Jun Zhao wrote:
> V3: just remove noop ff_formats_unref() and add missing return value checks to suppress build warning. 

Tested, LGTM, applied.

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c
index 08af2dd..f54ce9f 100644
--- a/libavfilter/vf_hwupload.c
+++ b/libavfilter/vf_hwupload.c
@@ -74,17 +74,15 @@  static int hwupload_query_formats(AVFilterContext *avctx)
     if (input_pix_fmts) {
         for (i = 0; input_pix_fmts[i] != AV_PIX_FMT_NONE; i++) {
             err = ff_add_format(&input_formats, input_pix_fmts[i]);
-            if (err < 0) {
-                ff_formats_unref(&input_formats);
+            if (err < 0)
                 goto fail;
-            }
         }
     }
 
-    ff_formats_ref(input_formats, &avctx->inputs[0]->out_formats);
-
-    ff_formats_ref(ff_make_format_list(output_pix_fmts),
-                   &avctx->outputs[0]->in_formats);
+    if ((err = ff_formats_ref(input_formats, &avctx->inputs[0]->out_formats)) < 0 ||
+        (err = ff_formats_ref(ff_make_format_list(output_pix_fmts),
+                              &avctx->outputs[0]->in_formats)) < 0)
+        goto fail;
 
     av_hwframe_constraints_free(&constraints);
     return 0;