From patchwork Tue Aug 25 14:09:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21917 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 887C844B6CA for ; Tue, 25 Aug 2020 17:10:28 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BEAF68AF49; Tue, 25 Aug 2020 17:10:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C12468AD50 for ; Tue, 25 Aug 2020 17:10:23 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id o18so16728050eje.7 for ; Tue, 25 Aug 2020 07:10:23 -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=pE3PElGAUF9MkZCEn3StDg0/SZrK3ohQtd7sm3NQgy0=; b=j0Twwjum4Asy9xal9IUHbK9giKfmNjEgTGG0+Isd8rRGxE3bFuuw3/CKeTWnXGq8mR zQezSFhco+u89KrEC7U+hWSUhGOSUH27yQd3oRQCHGmRUXfcOQ+78Y6CsG7JGvIBcBiy a22VBApZ+YtTPvLxCecGGB6rMt5DHx0ISVESfgnSqjXqAiQz21b3Sj4arTaQB3BUrzZF wcvzrxAzv5h8NOpOIfYed4WR5qTcGLy3eqj6/Qm4z+QkkTQSv0MadScyxRv4lmsJqid9 6vIZA258J7Zt+jQNids/TRWQmbM2qzNxS5YRaGMPegEVjTASTE8kdMLLZWBCOFvpg9Ok wz4g== 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=pE3PElGAUF9MkZCEn3StDg0/SZrK3ohQtd7sm3NQgy0=; b=ajFPm8zL1QOKxhdm3BBZ8egKSVgYNLgQ26oT4jMHeu/6Ryv4BSOkhaVAoxDmMJ575I slwGVIusJIxoCXTV7PJBExwp/dacVWeFjsG66Y5BF7IE0JG270bBb9H9Gh8YMl2PbeIm Ch1kX4bLG6nTLC9QWKo+RE3HmEMPPhNVmVhoHmQeqTn5VrDZwPuXPMnl7YX8yd7DnTms tYt3SnKENth1T+SptXh2Tx6Ddg3NqZ3djq5p6DIgzhGx0pWDYFGDhg8Unmxd5lF/C9SJ Nw/rDOxyQwB0Vc5i5z5n+4vn+hsIvo7FFoYJFDsTT1uLgFk5NbxzQPL3/zVIGrWXgij3 3i+A== X-Gm-Message-State: AOAM532ExBQ2OIUkLgU26yN4lNIMxl/yHNwlyIPyal6/Z8fc/3m/WmZl haQFzK+ZrFYq8oxk9Bs72yxeENDr1AA= X-Google-Smtp-Source: ABdhPJzf/tpUXQAI8kottbZU0mdIRaGUNS4O/A754KZSVuRUqX8sqeyTpRMmkoQhijQGP0I59BXgVw== X-Received: by 2002:a17:906:6608:: with SMTP id b8mr10506333ejp.317.1598364622387; Tue, 25 Aug 2020 07:10:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:21 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:24 +0200 Message-Id: <20200825140927.16433-16-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 16/19] avfilter/vf_signature: Fix leak of string upon 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" If an error happens between allocating a string intended to be used as an inpad's name and attaching it to its input pad, the string leaks. Fix this by inserting the inpad directly after allocating its string. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_signature.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index d09003746c..80957d0047 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -663,6 +663,10 @@ static av_cold int init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); + if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) { + av_freep(&pad.name); + return ret; + } sc = &(sic->streamcontexts[i]); @@ -679,11 +683,6 @@ static av_cold int init(AVFilterContext *ctx) sc->coarseend = sc->coarsesiglist; sc->coarsecount = 0; sc->midcoarse = 0; - - if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) { - av_freep(&pad.name); - return ret; - } } /* check filename */