From patchwork Fri Mar 3 01:35:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 2736 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.31.14 with SMTP id f14csp42743vsf; Thu, 2 Mar 2017 17:35:46 -0800 (PST) X-Received: by 10.28.159.73 with SMTP id i70mr454266wme.78.1488504946310; Thu, 02 Mar 2017 17:35:46 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o191si848094wme.129.2017.03.02.17.35.45; Thu, 02 Mar 2017 17:35:46 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 331F8680A00; Fri, 3 Mar 2017 03:35:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f41.google.com (mail-pg0-f41.google.com [74.125.83.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 169FF6802BB for ; Fri, 3 Mar 2017 03:35:24 +0200 (EET) Received: by mail-pg0-f41.google.com with SMTP id b129so38069830pgc.2 for ; Thu, 02 Mar 2017 17:35:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version; bh=O8H7Aib4MjBqLaHmbuasA4mwpwdnjaKwKXfAf5fuP/I=; b=SoI4UI3f6D1B+0fatkyjQU6GCj3AmNWtChmh76JyYiLll1TPUv4bUKBQOu7kPxKZP2 jyumvvl4uSJQq+K3jMCbCJx1P1yah8eCbWHkXEZP1Hbr0GI/8dSLuOtz8lH1kYwq+ZVg 0n6LxG84iNoy1lL0A3ljzUIg9JdYvbJFlSNM+qMjlvxheOTUd8Y7G7WhVe1oY91H3BsT y7Sug4mJKfUPYiFRBl+iwMzgrTacy0jrmPMfh6Zrg46ONv/mBxGP+PlX0TgPleAbtBjk e+TRydL15gXrYnsgHgaQPdBxahP4+RUWYkIdYR3NyekbGXom3ZYHMWTy6pVTSwSDkxOp 33pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=O8H7Aib4MjBqLaHmbuasA4mwpwdnjaKwKXfAf5fuP/I=; b=d3/Ayt19Xw5/rsTJLQ5OLAGnT7RghduxZtJWFbwF8doGK80kZT1A8aH1NMJ83j4aOk aloea8il8O1N+BDvKju47z/scvOosoNmMXZrImTKCZAF2PVfTH1D53/abdaxu+FIG4Pi Xiden1UxIV/oP2oI2bbEmi3/V4E7vtTIcB/kTRnxmqAQUOZr1FGBHPPZd3Bi1wU3i+US OanDC+xi9PIh8RHCi67CJcan3OSMT0LKFvR3r+270gZy0nauwR/wjqbArtg2BvTkyCKO ShYmTosphZYXSFC2lMmUQS4OY9XFIN7yWZWi0oOdl5uHeHccCL+nLl4vpMS3JT3fuPrA dyww== X-Gm-Message-State: AMke39nKS35iQQYtpm5Iix9nbfGlKoAQqGD2B1AXQKI+9YMNExgPjjvFLkK7Ha8CPR6nyQ== X-Received: by 10.98.61.209 with SMTP id x78mr335567pfj.88.1488504933780; Thu, 02 Mar 2017 17:35:33 -0800 (PST) Received: from [10.239.204.195] (fmdmzpr04-ext.fm.intel.com. [192.55.55.39]) by smtp.gmail.com with ESMTPSA id 67sm19347612pfd.120.2017.03.02.17.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 17:35:32 -0800 (PST) To: Mark Thompson , FFmpeg development discussions and patches From: Jun Zhao Message-ID: <7e509f99-3b6b-25a3-47de-c4c2c88ad743@gmail.com> Date: Fri, 3 Mar 2017 09:35:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2] vf_hwupload: Add missing return value check X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" V2: Fix the potential memory leak.2 From eb283d277679b5dac9c43e8d3c98bcc9367b592f Mon Sep 17 00:00:00 2001 From: Jun Zhao Date: Fri, 3 Mar 2017 09:25:53 +0800 Subject: [PATCH] vf_hwupload: Add missing return value check Add missing return value checks and fix the potential memory leak. Signed-off-by: Jun Zhao --- libavfilter/vf_hwupload.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c index 08af2dd..4b63a2a 100644 --- a/libavfilter/vf_hwupload.c +++ b/libavfilter/vf_hwupload.c @@ -74,22 +74,28 @@ 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); + if ((err = ff_formats_ref(input_formats, &avctx->inputs[0]->out_formats)) < 0) + goto fail; - ff_formats_ref(ff_make_format_list(output_pix_fmts), - &avctx->outputs[0]->in_formats); + if ((err = ff_formats_ref(ff_make_format_list(output_pix_fmts), + &avctx->outputs[0]->in_formats)) < 0) { + ff_formats_unref(&input_formats); + goto fail; + } av_hwframe_constraints_free(&constraints); return 0; fail: + if (input_formats) { + av_free(input_formats->formats); + av_free(input_formats); + } av_buffer_unref(&ctx->hwdevice_ref); av_hwframe_constraints_free(&constraints); return err;