From patchwork Sun Aug 9 15:57:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21552 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 67C2B44B9EE for ; Sun, 9 Aug 2020 18:58:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DA6D68AA12; Sun, 9 Aug 2020 18:58:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E2A9A68A8E9 for ; Sun, 9 Aug 2020 18:58:22 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id c16so6973782ejx.12 for ; Sun, 09 Aug 2020 08:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SqfvqSDIZhzE+hoqAoF0a/+nQksMov8P6L6P0EWVVts=; b=hi6/Lg8+svrmzTsCCzIR018/GkVONDjnZ0atZKN14FR4LH7R7wZCUuaPUKFBzHH39P MZDzXxtQtqmwf+tGPvngPmkjeYo+HlOFBEQdNi3yX7n8JFGxmjhEicHAobg5gNhUJwpq afA7RwluKlUepXeHKKidXIBDtw5auhaDFij2bwD6L5FS1GZedImn/+sAGMkqqJn+wfwh n3GDFGnC+35e4mDYYlpy1J27agqlK54E4YaxXfiAnEfEpafxO6Dwa35GAfiR/aZRPKYj dFQqL/LlkIu/tD+ZWaQu8laXZ+4SWiMkODS0XbybtlnUXEEzaoo0nlpZHJcoVPUcalXF OpIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SqfvqSDIZhzE+hoqAoF0a/+nQksMov8P6L6P0EWVVts=; b=hISIaSZGpAnOrb7EEVOInjJaL9KD60m4lwVBPNoevhSpdbp8WvVq/X4nDd1VZIh9qr yoNgCzy2KlWwn6KVqAlMNM+BmWsK6F5AX/5dKbHCikpcrcTUZVkAD1ZURwrNOhYQ1x0N gfbImjuB7aELg4vWtjWIJ9AaCHiKztfcwpCdf6mPykmg+dmJP6vvlcDlDgvrWSLu4Mbf lOGZNoyDuG/ybt4QaoUMBGnWtg5E05Fc20M4Ch9tMaqLJUuAw6nlMhdcKFLR8oowGaWT xTG7NCV5WUMcX0XmPGyMgZgilxCoAbo5hKemQwwax060YTd3xdnGkuCxq8Utnbpt25dV gy9w== X-Gm-Message-State: AOAM530L87lDI2b/ZRPETxRaAFnOdZwEDEwqo/l33GZfvlcf4K4MeXIq OsN1uqsrSyd7/ZNoWKVYcJVFsWEE X-Google-Smtp-Source: ABdhPJwXRB4B+sEU9VFeReolAZgW2kOuyNhLBUnDa0h7JB7qaTO9GtF77PFIgf6eHvjbWOobWiaHWQ== X-Received: by 2002:a17:906:1cd3:: with SMTP id i19mr3160130ejh.552.1596988702044; Sun, 09 Aug 2020 08:58:22 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id g11sm5360290edv.95.2020.08.09.08.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 08:58:21 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Aug 2020 17:57:36 +0200 Message-Id: <20200809155748.30092-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200808140202.586-1-andreas.rheinhardt@gmail.com> References: <20200808140202.586-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/21] avfilter/vf_vpp_qsv: Fix leak of AVFilterFormats on error 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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. Signed-off-by: Andreas Rheinhardt --- 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)