From patchwork Sun Aug 9 15:57:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21550 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 7E5B944B9EE for ; Sun, 9 Aug 2020 18:58:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B4C868A3F8; Sun, 9 Aug 2020 18:58:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F3D7689C95 for ; Sun, 9 Aug 2020 18:58:02 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id c16so6973251ejx.12 for ; Sun, 09 Aug 2020 08:58:02 -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=WUGcujyJbr3LMjp7wm9763W/6MsEkAIrKNhf3/mXqfM=; b=CdgEgo+NxxdLDgPDJkxC2x4h1FSN+swFO7+LlGOesGeoXLUyvxCFARATv1vVQTSnfl j7X6Ut91TqZw85uzXDeC1AdI0e/uvZrM9p3+QeZx+GXzYZIcuZGQ0TxpV89cdwCWHgSk PsSY0mYvJ94i9DMHyBQju9yXqJ7kN3nX7MGORTykQ5l/jtnZAa/QvMdr/teDEpoz/hnH jQ44DcC1i4SJHO8T0ncuNVGsQ1hdEcIMIpbDfrrtbtlmLTKhhFPzLG7F+P7y/99QheE4 dmDdZshoVCsWZTzZR/xGlYOg+APa0OJFsRf7oaz/tv7lLyiCytX3E7y5YITUNnD2uvQe 4ldw== 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=WUGcujyJbr3LMjp7wm9763W/6MsEkAIrKNhf3/mXqfM=; b=dOKeCGLzm4kX6DJnlEDpUm086tL1KuNc5ntKKJuh7CT22oc+SywRoIeZRGX1g6Q7s4 zvEL38LGvU9nwWxEAVwZlC+CTtoy7cuojQg/KPuaBpBpW8EZT7KBCVy1pW6EwLtY58F+ nD6iWfZ7eNfAvMJaxD79honjL9FyGZOhQcH+hua/SNh/OXHp2v6W4KW4qVjZnTnZYoJ/ 0XRDmokMhRcLO97LzAGXxl96jIDXo+6dx9YLNaeFHhiUkzuov1V3z/cCk8iqGQVSWpGG pvadXNIhcay+9/XGbpnEaIqwz7klyCqcSujMvmF5jZF34S6Zct5qPFTdPPS7LjLmqWq2 Jiww== X-Gm-Message-State: AOAM531ezaFqhXyh64H4z3O6agFdMUVf1Q+vzkbUAWVhQfO4PCKHKo1q L3njDmsQCS19m11d616s4ItjUr+K X-Google-Smtp-Source: ABdhPJy3luBFTEHA9qmnr5v1SCaQmTdaS3rDXFeV0KrDDNRM6wuJaDb8YQT0ty/Bakxs9tsHUCeK2g== X-Received: by 2002:a17:906:600f:: with SMTP id o15mr18536959ejj.41.1596988681039; Sun, 09 Aug 2020 08:58:01 -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.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 08:58:00 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Aug 2020 17:57:34 +0200 Message-Id: <20200809155748.30092-1-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 07/21] avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of 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 the allocation of an AVFilterChannelLayout and its usage (which involves attaching said object to a more permanent object), the channel layout array leaks. This can simply be fixed by making sure that nothing is between the allocation and the aforementioned usage. Fixes Coverity issue #1250334. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_afir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 5ba880f10b..6cbc7a00a1 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx) } else { AVFilterChannelLayouts *mono = NULL; - ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO); - if (ret) - return ret; - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts)) < 0) return ret; if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0) return ret; + + ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO); + if (ret) + return ret; for (int i = 1; i < ctx->nb_inputs; i++) { if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->out_channel_layouts)) < 0) return ret;