From patchwork Tue Aug 25 14:18:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21924 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 C6BC544B5DF for ; Tue, 25 Aug 2020 17:18:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF4E868AB18; Tue, 25 Aug 2020 17:18:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 41DE3689ED4 for ; Tue, 25 Aug 2020 17:18:45 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id o18so16768812eje.7 for ; Tue, 25 Aug 2020 07:18:45 -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=UnvnUuadgrUJn7p4ik6uFZ5P5e+lgra0d5jPa9YQmGc=; b=oo4rp8NKjog0YG+rjq7qD+SBCT4i/IvmreeonM1fEOrff41WVufOL4VIOCcBbavxM+ 6kkRMxK4puUNhlJ7zRCkIYzugAjslKmKVPMnzjflcfF0l21NEXaZ4fZvAPnMsVpGWr0i cVPT1uudArRORTYhKeWnyEqS67aKC0MpZXHulNH1nSZcW53EcrcipWT9RQY3QqYemy0P FRIwIFCwycU1ZuBNcS0jS8Of/tn4eSJ/oOamsmVCrcldCw+KfNPr3NQZlymJvkfs3aLx Ht3kzeSXwRtXxvCIeTXzj0oBbvqYjIxwSikULhDgq0d9XBFfN/sKtIDkNHsNMLCcD94/ 1Oug== 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=UnvnUuadgrUJn7p4ik6uFZ5P5e+lgra0d5jPa9YQmGc=; b=EuDCxEoBlHAKriGFm/r2K8UZY3kBxrIhGk0VSG9+Rmarf/3B5fS9G4zf7ysbi1/g5N xZ/8eTU8MR0Uu3q6Ngps2f7rBO/uhZJKDBBb2ISWKrfZJHx2CHTucWdFIyKTeAvU1wcm Yiv67aEqEbzMms1cjAHD80zko5hXPGaKkCw/UAeIvVjejxb1BigQaanjaR/A5AKxPJcx c/7IP56ciO6GKRhmJcWTFrnWhi4v+HyWmnzfiaHgtgll7X7BlQmm7iDz/2PjIMzQvdZ8 TnsAs/oTnw5WHiI9+sPVMLh9qE6HjUDcRHE/4hkV37b80sv6KD7gZkAraVAOb6YU1idq ecSA== X-Gm-Message-State: AOAM531S4iO1VC+0lI/gvRmvvbS0mGetLlzSZUvXihF1DvjF1CifctoM CPcuY5At65kXKsrmO0/TGRpdVpBn5Ns= X-Google-Smtp-Source: ABdhPJzoGs9DsnxwQmGwGWdO0r+HOsdo/iku6w2b/+YDqrxKvljL0Ij4zO4pn1yOV49IQW+M0+KYhw== X-Received: by 2002:a17:906:dc03:: with SMTP id yy3mr11267799ejb.380.1598365124350; Tue, 25 Aug 2020 07:18:44 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id yh29sm12887834ejb.0.2020.08.25.07.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:18:43 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:18:37 +0200 Message-Id: <20200825141837.6083-1-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 20/20] avfilter/af_headphone: Fix leak of channel layouts list 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" In case the multichannel HRIR mode was enabled, an error could happen between allocating a channel layouts list and attaching it to its target destination. If an error happened, the list would leak. This is fixed by attaching the list to its target directly after its allocation. Signed-off-by: Andreas Rheinhardt --- Forgot this one. Btw: Should one factor out common operations like ff_make_formats_list()+ff_formats_ref()? libavfilter/af_headphone.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index 751f4ab53d..da5acdce30 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -703,6 +703,9 @@ static int query_formats(AVFilterContext *ctx) return ret; ret = ff_add_channel_layout(&stereo_layout, AV_CH_LAYOUT_STEREO); + if (ret) + return ret; + ret = ff_channel_layouts_ref(stereo_layout, &ctx->outputs[0]->in_channel_layouts); if (ret) return ret; @@ -721,10 +724,6 @@ static int query_formats(AVFilterContext *ctx) } } - ret = ff_channel_layouts_ref(stereo_layout, &ctx->outputs[0]->in_channel_layouts); - if (ret) - return ret; - formats = ff_all_samplerates(); if (!formats) return AVERROR(ENOMEM);