From patchwork Tue Aug 25 14:09:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21907 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 5C81044B6CA for ; Tue, 25 Aug 2020 17:10:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4443D68A8C7; Tue, 25 Aug 2020 17:10:15 +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 4901668A79B for ; Tue, 25 Aug 2020 17:10:08 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id oz20so11774784ejb.5 for ; Tue, 25 Aug 2020 07:10:08 -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=DrH2bRdiGnuDx8lR3p5c21shYYke3Wo2t/wBwgdXgqA=; b=ckcgIq2GANSSFCTFhbMV4pJptuTSkoKa/eWdc2pacFlFTm0CpHZBas0ImieCZLSubf wHB+VemHEiiWCcr4xBjj2Kz6N6GiZ+R3M+cS+7BxhzsQxH8yY2GxSt49rCo0ZKBxOzc3 EeDZ9uT0Vub7/9UsctN9BjHYlNjynS/NlippeIhHw1SfDfMMudry2is8sNbvUmkXGok+ AWHjoswKxth//dW+DNfZ64OQH2pvMozej5MAf/PcyyaS0khYT3Yc/VSN5ZGFMx/ufGoy KFFIj2y5FuB/+3UitN/JnQ0/oppJ1VPRUr83jBWwUDJXGXbjYOaXk3h0iiy3JM8ssv8/ UBuw== 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=DrH2bRdiGnuDx8lR3p5c21shYYke3Wo2t/wBwgdXgqA=; b=TsymKpVjEgki/FSgT5M2HggV/Jmfor6E5BzWrvTlTQsFmP2p/lc/DcuZeSRQqHuN4+ GxbaxXFxunDyqvMm7SopyGn/KrxpDqjlZfjVzQtOOcjeH2tShhvpLBUD/nxMhpEIDny7 OPw4UTruH8NDJp6cv8KdBWnwal55HlW+HwzRVkPGeR1Z2/C1Z3dR35Ac14IP02hQ0Aiu qXLPGHfCkMgDBrSH15IhlITRcQQYebco9MlFsKOO7g7OOIJPgzN18j9tckfedo9HE3c2 48/2pKqp0nQENnpgjgwcILinuDF5zjNMVbVEtoG57JcaibGUhomZtIg32SBTQFJu8K0j JDqA== X-Gm-Message-State: AOAM532ZJLinHP5OoAphFoD1fjmUQsFCYLrcsa3bBsqVCXd3zrfV4o5v CxXZd1PgWwprgjtmfyxlPPn6OmEllEU= X-Google-Smtp-Source: ABdhPJxHaMFNSJc6RpyKJcOuwFbU8aHyyGRExvn1GVhBIbLUdsV5aK1A8WtcibDxbivq+hYQ6zCGyw== X-Received: by 2002:a17:906:c7cb:: with SMTP id dc11mr10307620ejb.18.1598364607276; Tue, 25 Aug 2020 07:10:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id k25sm10169806edx.96.2020.08.25.07.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:06 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:10 +0200 Message-Id: <20200825140927.16433-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> References: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/19] avfilter/af_anequalizer: Fix memleak when inserting pad fails 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" It has been forgotten to free the name of the second outpad if attaching the first one to the AVFilterContext fails. Fixing this is easy: Only prepare the second outpad after (and if) the first outpad has been successfully attached to the AVFilterContext. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_anequalizer.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c index 177e1c7b39..26cf835727 100644 --- a/libavfilter/af_anequalizer.c +++ b/libavfilter/af_anequalizer.c @@ -199,6 +199,12 @@ static av_cold int init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); + ret = ff_insert_outpad(ctx, 0, &pad); + if (ret < 0) { + av_freep(&pad.name); + return ret; + } + if (s->draw_curves) { vpad = (AVFilterPad){ .name = av_strdup("out1"), @@ -206,18 +212,8 @@ static av_cold int init(AVFilterContext *ctx) .config_props = config_video, }; if (!vpad.name) { - av_freep(&pad.name); return AVERROR(ENOMEM); } - } - - ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); - return ret; - } - - if (s->draw_curves) { ret = ff_insert_outpad(ctx, 1, &vpad); if (ret < 0) { av_freep(&vpad.name);