From patchwork Tue Aug 25 14:09:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21906 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 4FE8D44B55B for ; Tue, 25 Aug 2020 17:09:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 25469688379; Tue, 25 Aug 2020 17:09:48 +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 8DB0E68827C for ; Tue, 25 Aug 2020 17:09:41 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id a26so16750247ejc.2 for ; Tue, 25 Aug 2020 07:09:41 -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:mime-version :content-transfer-encoding; bh=J+IINYaHjIeSZI3V2/U0kjHjwqziLB/nkv/musfg4VQ=; b=aglEUIsbuAhef5EcsVaYjVDcpko3lp6pr1w55KGa4XcJIXvIRi+h8co20yqV3PRxKh vzoyOFPXjn9rAqGLYGTXWG/6pRYYBZBEthvQUHEW1sRaZxp7RDqXIY77Vo+0yLaQXsW1 1PnbcX1m5M4UEfZCDHbpRtyDBJhD5/Ht7OGiNvWcm8GT0/uI9a7Xopw30DV1HvYYz9Gr lVlRpLLfjCxCxVZSXPWG05QD9bGP1S+flwTz4//mfWT6nicqExIcwSwLDl2BZRbfWsYv vl7PjB4lvg+VGUFUrqdKUxM5B7/RhOy6m7arKPoWSNCIFSrOc6xPPlKPW6ZIkBG1ijbP rPjg== 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:mime-version :content-transfer-encoding; bh=J+IINYaHjIeSZI3V2/U0kjHjwqziLB/nkv/musfg4VQ=; b=if1OPOr80ipW5Rk+/bcBIwcTu0+s2UfD1mUTxf8hOs1SwJ6NSDrzRkgKx52rsR4edj JScI2ylE4Ju6Y5ExJ2ih4CHPJdTcSXWY6ehAt+MsiSJ5D0nNvwqamfx1xDuixty87qno 1Ac9RMPEzs2YtP1GTwi8VbLd8yd9f5QvWP4Ncf7x1AoetDxyzKt+Vac4xzhQx3DEU7Y4 AA0dD5F9Am8Y3Xt+jFvl5HQBtWGso9wvlXDeIb+2qtOzA0NXD2KxgUMotKy4+f4SdBrV uMenRgD4q8uPFEqrg8rpCEaYeOnJgdXKWCAmPmlbWy7/hPW2ti0L+IRrQN2K467j6EdK wQ1A== X-Gm-Message-State: AOAM530pxZv2jIyLIvpcF9DjOHSTXQi0/6mifwNWb7uBYLZNloRndY8c tl+6oynB2bjGD2Ywu8vtKG2B/KP7vv8= X-Google-Smtp-Source: ABdhPJwVST5I4STV00eS7Adm3ErPLKAPSkOgSr8v48Pl0wWBchsv44FYLsE3SmCy+cfGynrIYUx2mA== X-Received: by 2002:a17:906:38c7:: with SMTP id r7mr11058589ejd.118.1598364580674; Tue, 25 Aug 2020 07:09:40 -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.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:09:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:09 +0200 Message-Id: <20200825140927.16433-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/19] avfilter/avfilter: Fix indentation 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" Forgotten after fdd93eabfb2644f541f7aac9943abce26776ea73. Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index dd8074e462..cf3b4e461d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -857,17 +857,17 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, return ret; } } else { - av_dict_set(options, key, value, 0); - if ((ret = av_opt_set(ctx->priv, key, value, AV_OPT_SEARCH_CHILDREN)) < 0) { - if (!av_opt_find(ctx->priv, key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { - if (ret == AVERROR_OPTION_NOT_FOUND) - av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key); - av_free(value); - av_free(parsed_key); - return ret; + av_dict_set(options, key, value, 0); + if ((ret = av_opt_set(ctx->priv, key, value, AV_OPT_SEARCH_CHILDREN)) < 0) { + if (!av_opt_find(ctx->priv, key, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { + if (ret == AVERROR_OPTION_NOT_FOUND) + av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key); + av_free(value); + av_free(parsed_key); + return ret; + } } } - } av_free(value); av_free(parsed_key); 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); From patchwork Tue Aug 25 14:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21908 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 7F30844B6CA for ; Tue, 25 Aug 2020 17:10:17 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6050968AA85; Tue, 25 Aug 2020 17:10:17 +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 2EBF168A79B for ; Tue, 25 Aug 2020 17:10:09 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id dp2so11442535ejc.4 for ; Tue, 25 Aug 2020 07:10:09 -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=7JwcR2kSvu5wofYDafOSkok3TL6pUgf1m1O/GZgzuRI=; b=awyMuYUrQMikgFQcS4M3P+NDATQgike3zoEfoQvZLP86hI5Ir/s3+9y4TOsczfR1Iq 7yPYDPV1EnPs4mMqgwYz7RY315C8i/aPmlPqZj/AorJmIn8akolQz/pUGYthZ59uixFV 6Mn2DA+ESVlkjCLdk17ZdCT56gNFVMSs4bBZK+Z9Nc7RqdsoZdrJi4wkTZ9HbthDb+xE /gMcSZ6ooTB47BnKMwJNwMt/pkdHuR2JF7f4yU5MlfFouDz8LEJfpfzDP7bFJBU2lU94 sSwUwo5IwR+x2HT2Zf5NH5PRqgVw6yKbC9efZcNrFbyKwga0X3mvzZ24qJnqJeZc1xhA ktDw== 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=7JwcR2kSvu5wofYDafOSkok3TL6pUgf1m1O/GZgzuRI=; b=mcc/bcWXH9AMakmyf/11BVYXoj3ftFNMQoOrPZuTEWPqgaI9wnhrex5ctLBBigxfBG 6huaadBdyt1ufsq9odS+FYAeQwCvyR8PbvvMfJqgF/Y/TviTu36oxkSqWSRM0lR27rSU UDPnckmgPXb8WWxoPcWUE/rymeVStm88ezLbk/ctrhV5RpudTRnUOTloqbMbCXsBqyA0 p/KgKaKZCYknw4/emhH0O0vETgsKNad5lddHOD8LLFn1FWfMcY4d0AN3Dwdtqssdt4UP gYj7dDegPEmoG4xEyt+NGe8p/0kHIv5cqr9cLB3oYLe6HQPHfevrtDX6yg+gPbwmEyub 43bA== X-Gm-Message-State: AOAM531TFJVAtPs8ceB5Dr86Z4dbyUU6llaQ8GIm51xKJjnoeZFBfLHu JqPMdACzs/WZzoD4MSo2tcUFyD0VOKs= X-Google-Smtp-Source: ABdhPJwmAbAIo6eo4Fmf79COJeNIikC4inpOtJbNvd59IzdsiLthXi7XPQxpUYvwNNzvxdgWHJRblA== X-Received: by 2002:a17:906:e218:: with SMTP id gf24mr11241179ejb.469.1598364608342; Tue, 25 Aug 2020 07:10:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:07 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:11 +0200 Message-Id: <20200825140927.16433-3-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 03/19] avfilter/af_anequalizer: Don't allocate outpad names 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" These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_anequalizer.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c index 26cf835727..8cb607b2b4 100644 --- a/libavfilter/af_anequalizer.c +++ b/libavfilter/af_anequalizer.c @@ -192,33 +192,23 @@ static av_cold int init(AVFilterContext *ctx) int ret; pad = (AVFilterPad){ - .name = av_strdup("out0"), + .name = "out0", .type = AVMEDIA_TYPE_AUDIO, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } if (s->draw_curves) { vpad = (AVFilterPad){ - .name = av_strdup("out1"), + .name = "out1", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video, }; - if (!vpad.name) { - return AVERROR(ENOMEM); - } ret = ff_insert_outpad(ctx, 1, &vpad); - if (ret < 0) { - av_freep(&vpad.name); + if (ret < 0) return ret; - } } return 0; @@ -267,8 +257,6 @@ static av_cold void uninit(AVFilterContext *ctx) { AudioNEqualizerContext *s = ctx->priv; - for (int i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); av_frame_free(&s->video); av_freep(&s->filters); s->nb_filters = 0; From patchwork Tue Aug 25 14:09:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21909 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 5CC9044B6CA for ; Tue, 25 Aug 2020 17:10:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F9F168AAEC; Tue, 25 Aug 2020 17:10:18 +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 6616468AA21 for ; Tue, 25 Aug 2020 17:10:10 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id a21so756842ejp.0 for ; Tue, 25 Aug 2020 07:10:10 -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=IKINuTiYn5JgCQkyyTzql8zimScL90SosvtnKNoPwTQ=; b=lo/86ECG0g0BCosBlZgQ2xjr2rm+E3xqFhckX9daaB6WXW/xWjifYKO+lH9AgERxyb Ta3WRJC5qmyh3cuYvlnNBZGttxos4qX/RHp6yd7MOpb8LjaVWl95ZBzZSdMW1VvwH3x9 KrimFEoJf8cIjj3Bcl1yDZQcXRXoj6Xa4Niaih40gGkERanMtuOaPvHHlM7Fq3FQ0Luc MKDEDZb9lhCEXoE25vvn/XbH3gU7/x3hNhVWPwOW/jN+yyoWTh8/X2toDPO8e++QfJ20 PbMAPFigQae0fZdGs6bht/kUFMIJpbbR/K8V/X7ddbIlaZvZJhWiDztfW7lkD+bBc4+H XNLg== 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=IKINuTiYn5JgCQkyyTzql8zimScL90SosvtnKNoPwTQ=; b=Iu51wB7Xdi9L8MetUhdHT9sg9ehODicyDhKN45DG9aqtS4P2ig7QFzJef5ffDLzxiL N35nJsKFmuP+RcXkHRsOpdNYEn09UZZH+nVC/dodnKPfF9flLciS6EhqAXO4dQFQgI85 7IFk2Hrn6ySq3Ly5pJcE1VfaC0dpTj1bRiZSeE9S2Bi4JySC56RBdUOf5BFnlDLMNfDB 3UjEVZ0uk92dNRXxcU8UQamUGroY9xjdziH+5xmfTdLTTtscGzAyw4rmXztm7UN2rq25 Lqd0ASAFZIx1ICNppEtZhB1Q2zg4PpJlR4kk3TljIWCl+ds+BOBLjBTK9qPJwQhgxqzf H+/g== X-Gm-Message-State: AOAM532bKXKUwY+5mxga4tCN4FmKjfWm9pGtLPtj2O3elzTjGDWD0DFs MiIOrg5WlwC9Q9danUFOFpWhYfHraPY= X-Google-Smtp-Source: ABdhPJyoSWy700RW/RMzIvAZRLsmwgwmxFTRuiwTQ3SxgOXupvHLN5eIh3FURXWrgBX4+JFa9Fds8A== X-Received: by 2002:a17:907:7094:: with SMTP id yj20mr10519953ejb.471.1598364609558; Tue, 25 Aug 2020 07:10:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:08 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:12 +0200 Message-Id: <20200825140927.16433-4-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 04/19] avfilter/vf_premultiply: Fix leak of names of inpads 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" These names leak because freeing them in the uninit function has been forgotten. Instead of adding the freeing code, this commit stops allocating these names. They are constants anyway. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_premultiply.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c index 1fef4777de..5d053b1f77 100644 --- a/libavfilter/vf_premultiply.c +++ b/libavfilter/vf_premultiply.c @@ -673,27 +673,19 @@ static av_cold int init(AVFilterContext *ctx) s->inverse = 1; pad.type = AVMEDIA_TYPE_VIDEO; - pad.name = av_strdup("main"); + pad.name = "main"; pad.config_props = config_input; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0) return ret; - } if (!s->inplace) { pad.type = AVMEDIA_TYPE_VIDEO; - pad.name = av_strdup("alpha"); + pad.name = "alpha"; pad.config_props = NULL; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0) return ret; - } } return 0; From patchwork Tue Aug 25 14:09:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21910 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 35C7E44B6CA for ; Tue, 25 Aug 2020 17:10:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22B9568AC48; Tue, 25 Aug 2020 17:10:20 +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 A9D1268A8F3 for ; Tue, 25 Aug 2020 17:10:11 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id m22so16692630eje.10 for ; Tue, 25 Aug 2020 07:10:11 -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=yMMjMxgFgO5dCeL8hcjdG7YjRFc11ksEVusHHtANIVc=; b=jVOBLry2pIPEEQfMulg9xfL78DJwsUaFPr2bMflDIrLBtSmdH5+7w9yKQF1BzL5Ukm uQV7DNPYanA9CY3CanZKXOhU4mQ0TUyp38DNu4J2eawngYIXCW8r/A2qkurG9OKTHkvd RaMRlq52ZCKE/ye7EU4Ur28ebgiRB/zXhaNaRs/M7VUhuzxggy943XYUM84YWM2h+Zfm y+RHsEEn9DZxBkdyv7Gz/mqsfSjKv4MZoECnRzB1i+y9JfllACQQr/oE1/c4bwgnZ7+3 Og8ZvZ//l0ulUQxQOXEDEgx09d1bkGtDs3jZw0yvi3HKWnYawjwPmrK2CVv9V0+yjUpr rX6w== 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=yMMjMxgFgO5dCeL8hcjdG7YjRFc11ksEVusHHtANIVc=; b=MlhmXcTImN3gpdQFZQGe9vU0bJIh3lUAWQ4amJkwHsZoiq+3tTMqPutzNHD2f/UF9z /PP427z3evbzLnRvitY8hrRyYEHX+69e/PM110L8WY08lSdUHScEyixCmQmgt6XwwOXU 5CDkrLe6JaPCbW282rCcqMZN8vHcxAMBgz3B1AKja27HChLeK+I5wpscSlnRSJKMsv9W Uwy2m9R53V0fSvqmzYh/r8x06ToaF27vUSPI+2/IPnZic2xLm4QRdrv7eMT++1VWQguQ OBQRUZzHtDxg/MBLsDW580X54oBpxDd8Pt/9GdMkz83T6apgO+FcLTJbeWG5iQn+CA4l Fg5w== X-Gm-Message-State: AOAM531qraKJqgu5ruQbIRHwy46HW+7FUM7qlo4I6zAEIoOIPadK54Em t1a82a0Q2NTrCPyGldzVRKjmLihf+CI= X-Google-Smtp-Source: ABdhPJwXzdrye3IM1XX4E/gdQuOWeDxGK7JicZsRF8e4+wakDWLD1y0N1D31ZIFzDMS0tPx6PGfFJw== X-Received: by 2002:a17:906:c10c:: with SMTP id do12mr7230406ejc.92.1598364610764; Tue, 25 Aug 2020 07:10:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:10 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:13 +0200 Message-Id: <20200825140927.16433-5-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 05/19] avfilter/vf_fieldmatch: Don't allocate inpad names 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" These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_fieldmatch.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c index fa4aa8239c..7fcad18caf 100644 --- a/libavfilter/vf_fieldmatch.c +++ b/libavfilter/vf_fieldmatch.c @@ -964,28 +964,20 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx) { const FieldMatchContext *fm = ctx->priv; AVFilterPad pad = { - .name = av_strdup("main"), + .name = "main", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, }; int ret; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) return ret; - } if (fm->ppsrc) { - pad.name = av_strdup("clean_src"); + pad.name = "clean_src"; pad.config_props = NULL; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) return ret; - } } if ((fm->blockx & (fm->blockx - 1)) || @@ -1004,7 +996,6 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx) static av_cold void fieldmatch_uninit(AVFilterContext *ctx) { - int i; FieldMatchContext *fm = ctx->priv; if (fm->prv != fm->src) @@ -1021,8 +1012,6 @@ static av_cold void fieldmatch_uninit(AVFilterContext *ctx) av_freep(&fm->cmask_data[0]); av_freep(&fm->tbuffer); av_freep(&fm->c_array); - for (i = 0; i < ctx->nb_inputs; i++) - av_freep(&ctx->input_pads[i].name); } static int config_output(AVFilterLink *outlink) From patchwork Tue Aug 25 14:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21922 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 7DBF044B5DF for ; Tue, 25 Aug 2020 17:18:04 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 602F968ACE4; Tue, 25 Aug 2020 17:18:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 607B168A79B for ; Tue, 25 Aug 2020 17:17:58 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id r15so12854159wrp.13 for ; Tue, 25 Aug 2020 07:17:58 -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=VwZVdvUIEuel3ogR2g2VCGkjx6eF5qjbmM25DB3WUOI=; b=fUQLOWG+Vc0+7FqHc9c67OH/wehXgdza+cJJ0ERhQhpkXqFMDQYshj+KakbfhB2E3D HEYNAy/QJ9wrgdudNwptdsYqnDkO9clpgH3+MeTKOH2/sq7bd7mTQ9bsdAzGOuMbPnvm c1WPB1jJ6h8QiX2q3x+uYaA4zsTQtfc6aPh8/DwTOfMga/nJQYOKgUVvvN2GMa/a1aSv YBWTz7iAouuwoykXophluW+svCjZPjzFI5KRyzKDtbIUbZDrwxih9+Lww6dihTLusAPO Un2siyjZ+K85+DAEgWGhtw0mhSruYKjWWjwxZ2JDCgYGRUGDbLVAaSD/y8+OPe/BL9wX zedg== 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=VwZVdvUIEuel3ogR2g2VCGkjx6eF5qjbmM25DB3WUOI=; b=I9jdmuNTPsosn/4DLi4Im9Ss/HGAeNODDd85VuV+j5zIQt6I5SApBCWrwRHmNBCNFo OsSXCRGFWMZqCNGT31V4H+dVk5P8V7jd8AB6dZypATWlTWZ3YwaO/3jsbwlh+ulWlHC9 XA1NMC5dTbjI77TDnbHSPpk9QgjcupgSj7wI6bEJsMl8UGoKSI5fvqW8yXOPDvR4/NPo II7YZKaySWeGWIZrcRl+ooPjf4bZmI+7yMP9EhBRfsKlbg/3BD3GZ3kSempT5Tgh+95J SbwfeI9YwY72o0jVAB7fmk20w7OiYDEFAM0uRkPw8Sux1oteepWtHfMy7hx2wHKHk/Bf KQxQ== X-Gm-Message-State: AOAM5322Z23L05DLn3j+iW3Llswi/4Y6EXEnoBQflursI0a9u4kXLL19 Q0WrdNPJUoWYwyQPsFsxj1VlhBF2JBc= X-Google-Smtp-Source: ABdhPJwl4RSuvQwodq8Dx4SE6+yK4QE0FZTJe2AlGz0+qjCUfO5yf+x5mzNcfRhjobDw1aktF57UCQ== X-Received: by 2002:a50:bac2:: with SMTP id x60mr10691413ede.210.1598364611658; Tue, 25 Aug 2020 07:10:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:11 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:14 +0200 Message-Id: <20200825140927.16433-6-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 06/19] avfilter/vf_decimate: Don't allocate inpad names 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" These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_decimate.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c index 88a8b38a58..549b281418 100644 --- a/libavfilter/vf_decimate.c +++ b/libavfilter/vf_decimate.c @@ -273,29 +273,21 @@ static av_cold int decimate_init(AVFilterContext *ctx) { DecimateContext *dm = ctx->priv; AVFilterPad pad = { - .name = av_strdup("main"), + .name = "main", .type = AVMEDIA_TYPE_VIDEO, .filter_frame = filter_frame, .config_props = config_input, }; int ret; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) return ret; - } if (dm->ppsrc) { - pad.name = av_strdup("clean_src"); + pad.name = "clean_src"; pad.config_props = NULL; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) return ret; - } } if ((dm->blockx & (dm->blockx - 1)) || @@ -326,8 +318,6 @@ static av_cold void decimate_uninit(AVFilterContext *ctx) av_frame_free(&dm->clean_src[i]); } av_freep(&dm->clean_src); - for (i = 0; i < ctx->nb_inputs; i++) - av_freep(&ctx->input_pads[i].name); } static int request_inlink(AVFilterContext *ctx, int lid) From patchwork Tue Aug 25 14:09:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21911 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 2149544B6CA for ; Tue, 25 Aug 2020 17:10:22 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03F2A68AB82; Tue, 25 Aug 2020 17:10:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB92168ABC3 for ; Tue, 25 Aug 2020 17:10:13 +0300 (EEST) Received: by mail-ed1-f51.google.com with SMTP id k25so11330110edj.13 for ; Tue, 25 Aug 2020 07:10:13 -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=1QYcoMDuAGXN4nkamN0Fi6ewXPK8/EWf2QyFUJtdyUk=; b=KjDVHluJy9ftjCrtmQZCh7FMnOc1Jsfg7LK5NXxcVcVOuS+dUtTkFFf8XRUrJClQFh IiG+bp/zn2++YiM8GQxSoyDx4s6B96HwBgUMWwoj0P7AMHNukgHDGAOlNHyfpNZcHWtC sDYKLNsMgPk9XLHEIRbXL/iTy2EttXZXCoHczVG+YjOBWgIPL2SOhECqiMyqPMfcKWoo 2urT6ouqAX9gV3AQE6v0npAjAzAnnlg76J10l+21xuxy2Bvzoc1hnZr8KDQHPHcdbhGq mZISO/4T0vcdXJxVzchr+We386o9dM6g8mlJ8/CNkZPWx5YwWSLoAfqSzJQTAh5vmz+5 U28A== 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=1QYcoMDuAGXN4nkamN0Fi6ewXPK8/EWf2QyFUJtdyUk=; b=ISer0dKjJnbRS9YloAGcduaq5yEKq5zji/9lznkk7Ok1gMkhOllxKINtAB5bhKZna1 qZ7bmNMGRPYG0re2hf9rVwcftbRYx9ocBbXUw6UROrifPlhnaApHIdJIaFBAZx2C2EFA dadTEvoY4XB9JXLBHhHQuDMdI7P2Tx0+1Q/pBHCQiwrx6pu+692SOCprU8qJCabSp1bA 3pQpWEMP0Ou4XCbvbeaKbsj0dn5CV9TrR0IKmxEbohStYBiCB0Q38Q9+2sOYggwvPur+ GWqRA/uDbHR5aZcgK8e68vKajLEULN0W85mJ+JGFqRrQ3DR4lF1lb58NieSbpdQP6W2n oHTw== X-Gm-Message-State: AOAM531YeAIK3OGsd/yKVfCwcxQ6lP4p7s599/NTITrHqd26sGgxzyzx 9uRDNyrIk+4SNwc3rJrUR6/g6cxMFO8= X-Google-Smtp-Source: ABdhPJxmwSiXOm3pt0bjHQzttf4lQuLG65PAbt/lCNMj2Z0ntYZ6MkNkvevlpBRYL48UCOy1QQty8A== X-Received: by 2002:a05:6402:7d1:: with SMTP id u17mr10175145edy.48.1598364612764; Tue, 25 Aug 2020 07:10:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:12 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:15 +0200 Message-Id: <20200825140927.16433-7-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 07/19] avfilter/src_movie: Avoid intermediate buffer for writing string 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" Signed-off-by: Andreas Rheinhardt --- libavfilter/src_movie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 64d82e9df1..eeb8609855 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -213,7 +213,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) int64_t timestamp; int nb_streams = 1, ret, i; char default_streams[16], *stream_specs, *spec, *cursor; - char name[16]; AVStream *st; if (!movie->file_name) { @@ -305,9 +304,8 @@ static av_cold int movie_common_init(AVFilterContext *ctx) for (i = 0; i < nb_streams; i++) { AVFilterPad pad = { 0 }; movie->out_index[movie->st[i].st->index] = i; - snprintf(name, sizeof(name), "out%d", i); pad.type = movie->st[i].st->codecpar->codec_type; - pad.name = av_strdup(name); + pad.name = av_asprintf("out%d", i); if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; From patchwork Tue Aug 25 14:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21912 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 4FCFF44B6CA for ; Tue, 25 Aug 2020 17:10:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 35D9468AD72; Tue, 25 Aug 2020 17:10:23 +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 AC25368AAF6 for ; Tue, 25 Aug 2020 17:10:14 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id o18so16727300eje.7 for ; Tue, 25 Aug 2020 07:10:14 -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=2cKapQQ03jIL5kKTy1L5KKf41JhWoPXpdPNeFN2J/3c=; b=aGh9KJ2/Utzv48wGdQ8R8o3nCRpILscQFkCZvFQqWMpSARE8SYwafDimMUk9KDspik qrR4hEG3i7H71imHW+j/EtdcpDKhummoUleFx3nUXGepDZln/I6AI8afCDZQyQicj5Vv Tdjt/Jw9mGulIZBdFrZw5LOjM3iNgaPw0YJ81/n3lJWTJHbq+VsSi51wFgK+dg75+Olu T/5okBZfjNedVpgx5moQ8zAKiGAWs+lu1PUJuIdBawMyimi4DtgZdGA0NJNju+N388Lj 38DUm4pfHbVysZAFoSsVEGVw8x6yjYDsAbWvVZVrclDyFSKeYNTyOL5IUPJbbtY9mOr/ Dxxg== 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=2cKapQQ03jIL5kKTy1L5KKf41JhWoPXpdPNeFN2J/3c=; b=GHogcNscz7sG8Jt3mQdcMHvjk/cLcSeYRto84dabQ8DUyHJUzH78FugTVbPmKRb7l2 Zd0PvYfdTbTlRd7kz8O4gsARFsjodhJivfjKZNXJlnJ3xEcoOEaa5mX9AAHMxxucgXUs gQlD5i7LzKumNVzr4EooMGg6kxjTiZtzstLqsuzGWlzfvh4crFuwKkNNOJhjjkBCdqs5 Mlycl6Qjw2QU9kLT9TkhJdG1JfC2IBtEB/0V9FK5VYnG98uION4R6HcKsbphggladf7n 8YNku6RCPQ0fkWJXXTizPHe1GEScbVuiJqiX1B8pG9wwUcp91Tw0o4zlA/K6f3RZnPg8 tDPQ== X-Gm-Message-State: AOAM530fThnczBDdQ25AX8mmHI1em/H0oG5Ci3W8M2JtUP8v1rrPKdvr KzuG3oNKINVLAlBBt11gCLW1SEivC+s= X-Google-Smtp-Source: ABdhPJxyTy/7JiVgduLTRqughHHck9z4bRfMDKvn7fsSQYo0mATUgQ4ge6cABuc5Cgl9QCSUwCUKvw== X-Received: by 2002:a17:907:35d0:: with SMTP id ap16mr11258766ejc.457.1598364613695; Tue, 25 Aug 2020 07:10:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:13 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:16 +0200 Message-Id: <20200825140927.16433-8-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 08/19] avfilter/f_ebur128: Don't allocate outpad names 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" These names are mostly the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/f_ebur128.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 31b75ab097..5ae3dc25b8 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -527,30 +527,22 @@ static av_cold int init(AVFilterContext *ctx) /* insert output pads */ if (ebur128->do_video) { pad = (AVFilterPad){ - .name = av_strdup("out0"), + .name = "out0", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video_output, }; - if (!pad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } } pad = (AVFilterPad){ - .name = av_asprintf("out%d", ebur128->do_video), + .name = ebur128->do_video ? "out1" : "out0", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_audio_output, }; - if (!pad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, ebur128->do_video, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } /* summary */ av_log(ctx, AV_LOG_VERBOSE, "EBU +%d scale\n", ebur128->meter); @@ -990,8 +982,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&ebur128->i400.cache[i]); av_freep(&ebur128->i3000.cache[i]); } - for (i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); av_frame_free(&ebur128->outpicref); #if CONFIG_SWRESAMPLE av_freep(&ebur128->swr_buf); From patchwork Tue Aug 25 14:09:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21914 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 42BF844B6CA for ; Tue, 25 Aug 2020 17:10:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2E08068AF22; Tue, 25 Aug 2020 17:10:25 +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 A329168A9AA for ; Tue, 25 Aug 2020 17:10:15 +0300 (EEST) Received: by mail-ej1-f68.google.com with SMTP id a26so16753074ejc.2 for ; Tue, 25 Aug 2020 07:10:15 -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=jl3h69G2tRhuItC7MS9dIxwNjAGzFo2lKYx/ChbOWqU=; b=IndeCf9xWPf2+KPF0jaXGVv3thw776/00Txp4ml2sTjKOWzQXwUkD+4PBHWlOkq3Q2 kGM2HcOFdKc6j2BM3OWh957fOOjxjQne6jP7YakLrKFkYYZ1sUURF2HMMUf/3kOdluK3 QENR2x5XLOMSYu5DL5WnprM/pWJUrHV98l4sYVT6CM5cAy53/WTqh6uHC3JuaSgIV4Uc JMpqDp8ttrX9grthn5OKzF8TXHGtctpgFOInxY7lxgN1XLLgjXCyNkJ8hIMDWntbaALe V77L5K00IHX2Jg4CDIvpfsLJUhRTN/lrd6G2nepqBfSL2XnmMdC888NCAiSiR90yOSEH 0zTw== 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=jl3h69G2tRhuItC7MS9dIxwNjAGzFo2lKYx/ChbOWqU=; b=l5XtCatgukDa+NVrlehCjeraWSpiDGbphTH535Nh+CMYDMn79wpSeiz1GmlUvqpDcj WOaLyxcVBFyFdKJ868jfAaC0DZhAZACFGTJkKAbdZMMeirm1k873fOYkMlZTplUfDAQp ZaeN6WJ436/pt1TWRO4RrIA8fgPj68qnpcIKMz79n2VeEkhseBOyVBkGk2Uq3VBVIKfb I4HTRi2iDaevewrxdC69F1uTM0hCdTpTw2Qzg8MNswfpzgkvHBXHiWcG8JOkbFQW5UfY wN18Z6M8ArdvRJK+MLREsAiyF80l6Ow+ncRNt1by2cioZxRPP6loiyAOUYnS/NpL3DJ8 7ROw== X-Gm-Message-State: AOAM533z1vVDLMBsBoNclUDvJZQnsfaHBsJeaYpXw2GPO5INx54ZbcHm lXc2W+AFwzwUtA6NjQLCeBWQokgI1Go= X-Google-Smtp-Source: ABdhPJyiQrGR9wnfxufuHaf8wcztcDN+lDTYzDQb5E2QoQZjg/Su9gAmKtAqTUSZQV07V09qk+6/Kg== X-Received: by 2002:a17:906:2bdb:: with SMTP id n27mr11082534ejg.12.1598364614836; Tue, 25 Aug 2020 07:10:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:14 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:17 +0200 Message-Id: <20200825140927.16433-9-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 09/19] avfilter/vf_bm3d: Don't allocate inpad names 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" These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_bm3d.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/libavfilter/vf_bm3d.c b/libavfilter/vf_bm3d.c index e5d2b8bc63..18d13b25ff 100644 --- a/libavfilter/vf_bm3d.c +++ b/libavfilter/vf_bm3d.c @@ -942,27 +942,19 @@ static av_cold int init(AVFilterContext *ctx) } pad.type = AVMEDIA_TYPE_VIDEO; - pad.name = av_strdup("source"); + pad.name = "source"; pad.config_props = config_input; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0) return ret; - } if (s->ref) { pad.type = AVMEDIA_TYPE_VIDEO; - pad.name = av_strdup("reference"); + pad.name = "reference"; pad.config_props = NULL; - if (!pad.name) - return AVERROR(ENOMEM); - if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0) { - av_freep(&pad.name); + if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0) return ret; - } } return 0; @@ -1027,9 +1019,6 @@ static av_cold void uninit(AVFilterContext *ctx) BM3DContext *s = ctx->priv; int i; - for (i = 0; i < ctx->nb_inputs; i++) - av_freep(&ctx->input_pads[i].name); - if (s->ref) ff_framesync_uninit(&s->fs); From patchwork Tue Aug 25 14:09:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21915 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 59FF544B6CA for ; Tue, 25 Aug 2020 17:10:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 410C568AF73; Tue, 25 Aug 2020 17:10:26 +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 E1FAB68ABC3 for ; Tue, 25 Aug 2020 17:10:16 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id d11so16518128ejt.13 for ; Tue, 25 Aug 2020 07:10:16 -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=GVTIy8JdJ+5uIbmwiLo+WVtTGUga1c2pR/sSC/0OyjQ=; b=eqcEYmGBN2aPmkBwYEhGdFGcqU0FK6W3bRXgOe+D02SN68mvPZYElqfp6Xc05nj3TS PCBJcG1I1kkyfNjHsuJbtMIRE1WC7IMFu/zzmfkHqaz3wnY4F2SyfAId+3fiPMpXQbPd 6j6G0tR9FjfE0FgKeGuXSVT/W4NSqk3cRKu+63khJ4Vplp0ZAMmvRqyExTH4W6vj70Gk ra82f48Hq8Twqj0srDKZFuDF+9M9ApYSYgX4EEJai9QIBVHM5Gqt2FItuQFdj5z3wA4N Cjif6ng+NVrJhMTJbhbw9szQB665q+T2JByNT268e6Oo0n679AWGQFMIHrBpBRCvxp+h gsEA== 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=GVTIy8JdJ+5uIbmwiLo+WVtTGUga1c2pR/sSC/0OyjQ=; b=H3Zb9wdOYBLbhs71PDRbhgIGjjVSDNVN7bbg4wrx2ipcn6zNYI4OlccwTkzkVLKioZ QhI2D6otV6I/2y6KXzQwUQRp37X1a/9l+GTiqA+Yvr5HKi97T9NzJyWdCzVTcXSob70I a9G+EuS9//xw7XJRqqu092HiVbqJ9h+MBU6EPoDe/2SJDbpsrnYHzSmoejmNw9B2NlyH Oh+XrK7iCAgUVlEeU5DTd1nbfTYkAUrr4wFnzddhi2uwfvXBOYaO7tQ/6u7OHvpZ+iHY aujhP8GcXH+LbRw+vbqfHUfkYfKTAX7GCcLvvDYaYL96xUJPta9NY5o8xKpo2WeL9GWn VclA== X-Gm-Message-State: AOAM533iNjIhPZ54cLOBtqIo6h0NcW8tJLhaSFl8RCZsfVx5FCmFc3RU eUrvOSiotqQ6ngsRyM4r/aKnQAfBYig= X-Google-Smtp-Source: ABdhPJx7zbVOc7qiMfhBbJZBmeNcybX0RwPhFU1ogNq6hHpMcNuXMEP9kVmGPJvm99bt2g84l0u1nQ== X-Received: by 2002:a17:906:74cf:: with SMTP id z15mr10634916ejl.258.1598364616040; Tue, 25 Aug 2020 07:10:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:15 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:18 +0200 Message-Id: <20200825140927.16433-10-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 10/19] avfilter/avf_aphasemeter: Don't allocate outpad names 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" These names are always the same, so not using duplicates saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/avf_aphasemeter.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index be0b2fb70f..53d1de29d3 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -227,11 +227,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) static av_cold void uninit(AVFilterContext *ctx) { AudioPhaseMeterContext *s = ctx->priv; - int i; av_frame_free(&s->out); - for (i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); } static av_cold int init(AVFilterContext *ctx) @@ -241,30 +238,22 @@ static av_cold int init(AVFilterContext *ctx) int ret; pad = (AVFilterPad){ - .name = av_strdup("out0"), + .name = "out0", .type = AVMEDIA_TYPE_AUDIO, }; - if (!pad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } if (s->do_video) { pad = (AVFilterPad){ - .name = av_strdup("out1"), + .name = "out1", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video_output, }; - if (!pad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 1, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } } return 0; From patchwork Tue Aug 25 14:09:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21916 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 4DB2744B6CA for ; Tue, 25 Aug 2020 17:10:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 360B668AD2F; Tue, 25 Aug 2020 17:10:27 +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 BD4F268AD4D for ; Tue, 25 Aug 2020 17:10:17 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id dp2so11443289ejc.4 for ; Tue, 25 Aug 2020 07:10:17 -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=k8KwKloxDcl1QQVdlJZirb034eqZnGftLtOpZeBRNc0=; b=pLQ66laveNnIhPOEhWfIPkhphUNaPRWFdcQ5zdYtxZqk0sL6Wv0lKe+9LyPXjN1UI6 23/28EzcWqPkQFIf4d+H4Iub0OyjFNKXKJmRAgXSAPQfuV0mdTUfIps1kCH0Jz11p8s5 1nmf255wUi4iPscH44bUtnO0FHKnSx0ZLXKYK/e2HkZqq5uJqfb97ILnaSNplGMbQ+9H pyPPRJZ8/G6au+4lGDFbfx20jyo/2IvV4YOAjKj9FRBgRntN85aoLckwEdbQuI51UGro OOkJv4Ahu3tFrMXWzMjcZuyiVgaxsg88Uiq8kbKzWTr+NpJeg+x7Tx/BKHkIiTHN6GXW B+3g== 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=k8KwKloxDcl1QQVdlJZirb034eqZnGftLtOpZeBRNc0=; b=J2DguVbhAulChQBNzZ6O7G2l/njB0STtFH110c0R/RfyntxDJ7AJ/uKNtKL0D979xC cSlyOUm59Fo2eCUtOl4JzXvicwSZqJWoB5mzOqSGTXe1MuQ/Ko0cibfIkay9xBPMKICU eDo8tfadD4bM7SpJBDz43ETy6nLn7MR+H3FJgVp6nj7+HHZKLoQDFtgsMgxzAWCP/ePW /A+d8tmAbyk3nk28rHRRhrLVGUbEKQ6a6DUVeyou+/PnywVc+aL7oH+WsWzT+mXEh3ej ZUGL3KA0Q+x3fuHS9XM82s+oUGiPD1x7k2A/2RaC45VWdzJ4xD8Q6XJCki7pbid2/+xF VinA== X-Gm-Message-State: AOAM532X03Plasf4BrQXPe5irg9dl9cBIFQ+LQX7fTLVrE+VauSnqHt8 eOP3CJuxs3s7s79+UNlkcejtSa/K9rc= X-Google-Smtp-Source: ABdhPJyqlGtC+Ec8Sqc0cEec5GUGJ7vzbca4CsgqFxzk18x80CgYqv1BWIWbdsRDK4yDj8VSSWM80Q== X-Received: by 2002:a17:906:f957:: with SMTP id ld23mr9889697ejb.187.1598364616942; Tue, 25 Aug 2020 07:10:16 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:16 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:19 +0200 Message-Id: <20200825140927.16433-11-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 11/19] avfilter/af_aiir: Fix segfault and leak upon allocation failure 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 aiir filter adds output pads in its init function. Each of these output pads had a name which was allocated and to be freed in the uninit function. Given that the aiir filter has between one and two outputs, one output pad's name was freed unconditionally and a second was freed conditionally. Yet if adding output pads fails, there are no output pads at all and trying to free a nonexistent pad's name will lead to a segfault. Furthermore, if the name could be successfully allocated, yet adding the new pad fails, the name would leak. This commit fixes this by not allocating the pads' names at all any more: They are constant anyway. This allows to remove the code to free them and hence fixes the aforementioned bugs. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_aiir.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c index bc31e5141e..3df25b4d9b 100644 --- a/libavfilter/af_aiir.c +++ b/libavfilter/af_aiir.c @@ -1159,26 +1159,21 @@ static av_cold int init(AVFilterContext *ctx) } pad = (AVFilterPad){ - .name = av_strdup("default"), + .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_outpad(ctx, 0, &pad); if (ret < 0) return ret; if (s->response) { vpad = (AVFilterPad){ - .name = av_strdup("filter_response"), + .name = "filter_response", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video, }; - if (!vpad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 1, &vpad); if (ret < 0) @@ -1205,9 +1200,6 @@ static av_cold void uninit(AVFilterContext *ctx) } av_freep(&s->iir); - av_freep(&ctx->output_pads[0].name); - if (s->response) - av_freep(&ctx->output_pads[1].name); av_frame_free(&s->video); } From patchwork Tue Aug 25 14:09:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21918 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 87F6144B6CA for ; Tue, 25 Aug 2020 17:10:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 70EAB68B017; Tue, 25 Aug 2020 17:10: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 B0DDC68AD9A for ; Tue, 25 Aug 2020 17:10:18 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id oz20so11775639ejb.5 for ; Tue, 25 Aug 2020 07:10:18 -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=EdqCCZBtFGxmlF8nJTjLbW4DDmHV+6Skw1zQTkVO8wE=; b=nM0WXiAYP+JyPCYACCN2U5WnqKXq/d7rcX4aYBWVLQUFfuvXMckENk31KY9QOoc4mP TpSasfDB1MgoaQNmsgkQHjOv3RaFkEWaWFs7zPoVItZ8lUg/2QrR3/ioRImzgRA+1eXm l7ELNuax73mBfCwWOkMiwvh/Q0yqSsq14Kp2wfmnDUxAEr9e1qauzCeOSjLbMJ3sIUVI 9UVL7jiWj/XhacxOXM1bzymWExK96ypMX5U72b88IaBhhnYh2h1316LsoofqdjAq/If2 BWrFLJ8ElTSYeMnaGTRfc2q1LRNeXoQw2bXqlLIBZU5KhzHDK6xE9OWLwedU7dcqYtGg Rmgw== 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=EdqCCZBtFGxmlF8nJTjLbW4DDmHV+6Skw1zQTkVO8wE=; b=FTyuc1WneRhu5k7nPeYkQnN7ioAxDBbYxfNMmIU5f9+xmZJCVBJu/2WWTzKq2Csr8p NtwwSW2m1xj5vYlRTN8pzbtDRwLSlzyW8rr5OViUaIgen0pulBcLD7Mf+DdfU0TPneZb nN3+To0hd7OE1JFvHVkuifZXD7HxHD7XH5w/bdDYByaKkNVPZxHLV4Pbt7QgY/8QkSB3 aosKg1uWCDAAFVi9fTuwsNYTyz05NxbgAMGfiQfr67CxGVCbgK4e9OeaAIQQsGd+JKdE B9RKXtG99GHHNlYi2rk9bBU0nOSoBFinW21GXcHErIZJ8tSjhtPZ0Qp1jcVMYG/9ooEn /hdw== X-Gm-Message-State: AOAM533q2tN0hDFmPR+fbmiwxvRoEKxDk5a0ho5L2pv1BcVDxZSCumet fg+ebVzdZphuTBaMmFH6/YCB0zQ4Bkk= X-Google-Smtp-Source: ABdhPJyBsZgmZE1LvuEqtD1UAAIduWbXrvkAn46BZB9h9h7BRgHQsMv9en9vSjCVaUTeVYHqhArrlg== X-Received: by 2002:a17:906:e59:: with SMTP id q25mr4006734eji.143.1598364617834; Tue, 25 Aug 2020 07:10:17 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:17 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:20 +0200 Message-Id: <20200825140927.16433-12-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 12/19] avfilter/af_afir: Avoid allocating AVFilterPad names 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 the names are always the same, they need not be duplicated; doing so saves allocations, checks for the allocations as well as frees. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_afir.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 4e76bda4a3..d128f4bce7 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -800,11 +800,9 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&s->ir[i]); } - for (int i = 0; i < ctx->nb_inputs; i++) + for (unsigned i = 1; i < ctx->nb_inputs; i++) av_freep(&ctx->input_pads[i].name); - for (int i = 0; i < ctx->nb_outputs; i++) - av_freep(&ctx->output_pads[i].name); av_frame_free(&s->video); } @@ -842,18 +840,13 @@ static av_cold int init(AVFilterContext *ctx) int ret; pad = (AVFilterPad) { - .name = av_strdup("main"), + .name = "main", .type = AVMEDIA_TYPE_AUDIO, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_inpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } for (int n = 0; n < s->nb_irs; n++) { pad = (AVFilterPad) { @@ -872,34 +865,25 @@ static av_cold int init(AVFilterContext *ctx) } pad = (AVFilterPad) { - .name = av_strdup("default"), + .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, }; - if (!pad.name) - return AVERROR(ENOMEM); - ret = ff_insert_outpad(ctx, 0, &pad); - if (ret < 0) { - av_freep(&pad.name); + if (ret < 0) return ret; - } if (s->response) { vpad = (AVFilterPad){ - .name = av_strdup("filter_response"), + .name = "filter_response", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_video, }; - if (!vpad.name) - return AVERROR(ENOMEM); ret = ff_insert_outpad(ctx, 1, &vpad); - if (ret < 0) { - av_freep(&vpad.name); + if (ret < 0) return ret; - } } s->fdsp = avpriv_float_dsp_alloc(0); From patchwork Tue Aug 25 14:09:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21913 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 6189544B6CA for ; Tue, 25 Aug 2020 17:10:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 475E768AD22; Tue, 25 Aug 2020 17:10:24 +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 E478768A8F3 for ; Tue, 25 Aug 2020 17:10:19 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id a21so757604ejp.0 for ; Tue, 25 Aug 2020 07:10:19 -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=T5iEoUxqtE+RKgLCppji99ooivkYtyeHosdCGWVccyM=; b=JO+JRMWj4lYxi9sUxI0PN6bs4MBa23ifxYIELNu9674C1L2J98qnACAMxaM0/5R0G4 BcjfAjDQ392cCcDIvMBLHacJQDINwLMY2OTCbEW73RTrkDjYhZkXFURdOAC6DLPHXwOK YYOLDIyMCcagA5Driyco4TOpxkMyMBrDJlbYZBkuZMhzYmJO+yTKpC0wjzx9RbgOa0A5 qZ8o3Jedbczrmz3Ts0AKep6HIhvqX9IpdGThBR4xtUdm9sTHM6cLl/kJYazikl/v0ItO t/pZac6dt6+NviagrwQkd99saMfjW6J41S1FbhGRFyeki3uwUQgrCN+eKYEtNmVZqDR8 CZxg== 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=T5iEoUxqtE+RKgLCppji99ooivkYtyeHosdCGWVccyM=; b=GHd/lt9o41O7yKedXHjjx8oQmwzcn/RgGRk9xUs6QuxZh/RD+Y0LL+3zg4nLdj5ti4 zLxqSwSnbEybXA4tm64qs7UAMe4Xo652SgqPZqang3ulYHstsZox+BLQiwZz3O5kTGzA oaEeNeto4HxPwTClCBqqVG1bLI9O3TOa3ivN+sR9qZ20l96/cNyy7CrJ1q4aPeNa3n7e +oeYaSwLdgv+7OzcaVbhyVLMjf3UF3zpuHOX+pmuoj3EijnE9QZDLQGkhWXEJbFvmS13 m6Us2ymGG05lpl/ICQwoQSHCwMb/voF4EIgSO0i1XGk4M0HF/dtlC5rPSkrdSesKHBa+ 4AbA== X-Gm-Message-State: AOAM53185rY1/1uxtrOqEcneXypfYjlaoVo22EYg3QCJYuzu1eqFylBD 7ebsOAKOu3MZmuKotR+eBQXCPiiUxX8= X-Google-Smtp-Source: ABdhPJyGN66IxyXZ1e+t33IKroodWbJi+ZsK6q9Jcm4+Kag+n+RblseaXKqtUhYR0GXNMx6ObvCR8w== X-Received: by 2002:a17:906:71c4:: with SMTP id i4mr11222608ejk.347.1598364618980; Tue, 25 Aug 2020 07:10:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:21 +0200 Message-Id: <20200825140927.16433-13-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 13/19] avfilter/af_aiir: Avoid temporary buffer when drawing image 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" When creating the output video, a temporary buffer is used whose elments are only used three times: Once to store a value in it, once more to add the value of the preceding element of the temporary buffer to the current element and once more to add the current i. element to the i. element of another bufffer; the two latter operations were performed in one loop, whereas the first was performed in a loop of its own. Yet these loops can be combined and the temporary buffer avoided. All one needs to do is store the running total of the elements that currently are in the temporary buffer and keep the preceding value of the destination buffer (it is needed to calculate the next element of the current temporary buffer, i.e. it is needed to know by how much to increment the running total). Signed-off-by: Andreas Rheinhardt --- One could combine various allocations here and in many other places. But for now I'll leave this to a future patchset. libavfilter/af_aiir.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c index 3df25b4d9b..75bb79eb06 100644 --- a/libavfilter/af_aiir.c +++ b/libavfilter/af_aiir.c @@ -866,8 +866,9 @@ static void get_response(int channel, int format, double w, static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate) { AudioIIRContext *s = ctx->priv; - double *mag, *phase, *temp, *delay, min = DBL_MAX, max = -DBL_MAX; + double *mag, *phase, *delay, min = DBL_MAX, max = -DBL_MAX; double min_delay = DBL_MAX, max_delay = -DBL_MAX, min_phase, max_phase; + double tmp, oldphase; int prev_ymag = -1, prev_yphase = -1, prev_ydelay = -1; char text[32]; int ch, i; @@ -875,10 +876,9 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate) memset(out->data[0], 0, s->h * out->linesize[0]); phase = av_malloc_array(s->w, sizeof(*phase)); - temp = av_malloc_array(s->w, sizeof(*temp)); mag = av_malloc_array(s->w, sizeof(*mag)); delay = av_malloc_array(s->w, sizeof(*delay)); - if (!mag || !phase || !delay || !temp) + if (!mag || !phase || !delay) goto end; ch = av_clip(s->ir_channel, 0, s->channels - 1); @@ -898,17 +898,15 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate) max = fmax(max, mag[i]); } - temp[0] = 0.; - for (i = 0; i < s->w - 1; i++) { - double d = phase[i] - phase[i + 1]; - temp[i + 1] = ceil(fabs(d) / (2. * M_PI)) * 2. * M_PI * ((d > M_PI) - (d < -M_PI)); - } - + tmp = 0.; + oldphase = phase[0]; min_phase = phase[0]; max_phase = phase[0]; for (i = 1; i < s->w; i++) { - temp[i] += temp[i - 1]; - phase[i] += temp[i]; + double d = oldphase - phase[i]; + oldphase = phase[i]; + tmp += ceil(fabs(d) / (2. * M_PI)) * 2. * M_PI * ((d > M_PI) - (d < -M_PI)); + phase[i] += tmp; min_phase = fmin(min_phase, phase[i]); max_phase = fmax(max_phase, phase[i]); } @@ -975,7 +973,6 @@ static void draw_response(AVFilterContext *ctx, AVFrame *out, int sample_rate) end: av_free(delay); - av_free(temp); av_free(phase); av_free(mag); } From patchwork Tue Aug 25 14:09:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21920 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 8EFCB44B5EC for ; Tue, 25 Aug 2020 17:17:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A86868AB18; Tue, 25 Aug 2020 17:17:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C02C468803F for ; Tue, 25 Aug 2020 17:17:09 +0300 (EEST) Received: by mail-ed1-f65.google.com with SMTP id k25so11352063edj.13 for ; Tue, 25 Aug 2020 07:17:09 -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=9GD11jE0+W4fPkRry+b0jVPTU/yfxP5uv7LdLM50Bx8=; b=BVoho6i2nwnKNGTd9vtTXAOmqqNo8Geu0AjM4i3MFny9MeJCibqy1UyEkPsnTDbumM u93kkBCQsn3HkyH8n7EbtKQdP8dZMCC9g//JLvXrPFf8VXx/KZullbLDknZmvsTjI0m7 GQTTiI/ljMNP1KEHq4GXgatYuqVaTFxY/VlK2KeaK4DCavo+QgXU6Gf+E9FY0wrMbxaE P1n4yYVlwt8wclg6iodGlLCb8tsG0zJQnYn7ZSV15elrptw8fbvYmUOPgCwBJ4++QERu NlF6Uu+VN8baqavoK6OQc6Z6ICqRt4TCAVqoUr3OrIsPaeoomqP0q/vH0qJHK/UOPmgg RS2g== 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=9GD11jE0+W4fPkRry+b0jVPTU/yfxP5uv7LdLM50Bx8=; b=X6DJcmlM2/Qu1sLZ5E8jtaIHwWpCDzwFS3JP0Aj2paDAcNQjF8TNqEkEhaV+UT8T8h Zemuheens64N+/sylETbIW2PeVQnkhi3XGhi9mdu7gjGlDAZ1D3d479mpqrqJQ3M5mH/ 6s9+TyBKUpn2pETIeu/jUW6defz5wejlXxRM9+b+HvOKKxlnyL/mhNtv7YbbRtOYdQY0 e7bkbkZU14MNPOjaNeJcHrqM8ozOHYY+ZnXjeN4ytpuFfvARG1OscMOetIGp2QW3J6ur 0b1+tzivEHyVGIHP6T1CO3cFTjQ6EpVjIBH5U3zqX1L6WW3bnrYSbTM64Gy+AWiu8PQG KbQA== X-Gm-Message-State: AOAM5315AXQM6CMhM5/ivz247OfjQ/DQThgi73tsMmxTS4DSJbiXJhge sD4cRhy5eaQFOHblWI6ohvwsE02b2OQ= X-Google-Smtp-Source: ABdhPJw2Oap/zQyujDhHr4Lg4AQLSDySszCE6O3PoKfLuCqsIYCoqubWgJoDDpyKOEIiT8Hkw/AEBA== X-Received: by 2002:a05:6402:17a2:: with SMTP id j2mr10295427edy.79.1598364619964; Tue, 25 Aug 2020 07:10:19 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:19 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:22 +0200 Message-Id: <20200825140927.16433-14-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 14/19] avfilter/af_amerge: Fix segfault upon allocation failure 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 amerge filter uses a variable number of inpads and allocates them in its init function; if all goes well, the number of inpads coincides with a number stored in the filter's private context. Yet if allocating a subsequent inpad fails, the uninit function nevertheless uses the number stored in the private context to determine the number of inpads to free and not the AVFilterContext's nb_inputs. This will lead to an access beyond the end of the allocated AVFilterContext.input_pads array and an invalid free. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_amerge.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index ca94a224af..93f6f17d22 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -58,13 +58,10 @@ AVFILTER_DEFINE_CLASS(amerge); static av_cold void uninit(AVFilterContext *ctx) { AMergeContext *s = ctx->priv; - int i; - for (i = 0; i < s->nb_inputs; i++) { - if (ctx->input_pads) - av_freep(&ctx->input_pads[i].name); - } av_freep(&s->in); + for (unsigned i = 0; i < ctx->nb_inputs; i++) + av_freep(&ctx->input_pads[i].name); } static int query_formats(AVFilterContext *ctx) From patchwork Tue Aug 25 14:09:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21923 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 A013F44B5DF for ; Tue, 25 Aug 2020 17:18:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 834AB68ABB4; Tue, 25 Aug 2020 17:18:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D98956807F1 for ; Tue, 25 Aug 2020 17:18:13 +0300 (EEST) Received: by mail-ed1-f66.google.com with SMTP id q4so1579856eds.3 for ; Tue, 25 Aug 2020 07:18:13 -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=W8rJ32eSy6jX7g2g30cV9K0The53rnN6rOZA5MrNCHI=; b=jXQegihwbF4lje0KnDKLTtfVgswuOmcvQZG1/3PC5hsX/hG92oRXvQa8LPsLFV2VZd UKUGIZuo2c+UvTx4YRT8iD0yWwEhG3wmOjt17S+sznBgG5Hiwz1OeIpFzYAGeQzq24T8 V9hCUSvVQUbUEYFPeW4UWytUd+chYd/5yq7i37QtVlm9MHiqiO8ptZmG6FEcA5szSTj/ RLkmDqqzTy4QZUCldWxI8c6PkmYmagXv8rfUesZodXAxUW6S7iTEW29toJJplu2ToAWo 7C8MM5UqrMLx7EierKiioUIRWI6viO8VAYw3EzsQYa5x7mBfUP1MYl5zOOjAOsG4KVFz HmIQ== 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=W8rJ32eSy6jX7g2g30cV9K0The53rnN6rOZA5MrNCHI=; b=bOlhmkLo3LUtL94fjtaZt+80Oj/nSR0uOWogzudyrAxSxGG6e3CvpTh5qtl69lzgSD MJEpdqc0Q7ZQRi6pQlUs/mJM+0sHvVi96VBkQ+zAHxYBFyqted3bsrWhPUlHaZ0y6gBS oez1ae8OIcA71K5D7OtXkv5i4PTqfQyIqjrJ3RPc5vq6PajrKsdf3nWV0oCv/rZCKsJm R/fBMe1XyxV14vBE/7A+eaJtLB+EQyqxSgIlUDBk5xb9hHgFrMiqDdyxiIMXnZEPM8wX iTVMy8HH/NwN61V/I1SGTJwHlKJGjV5NlHG4BTKHspTlxtKbxLVgLomvCNXtSDFOC/ZM WhDA== X-Gm-Message-State: AOAM531Z3FM6VM9TJF6qLsk5B9JXqiKs7QtfX1JYjPVN01DDwaC7RK4T LqiRgaZ+ZVBsAmmBtejg4vO+cCJBf74= X-Google-Smtp-Source: ABdhPJwQEva1nE4/IXsDFaMhU6cUG2Ovutbc/fp/ZupayYdItX6uYHqHgq5/c18FJMGDu4P0vJTg5w== X-Received: by 2002:a05:6402:3199:: with SMTP id di25mr10623219edb.315.1598364621305; Tue, 25 Aug 2020 07:10:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:20 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:23 +0200 Message-Id: <20200825140927.16433-15-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 15/19] avfilter/vf_signature: Fix leak of inpads' names 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" Signed-off-by: Andreas Rheinhardt --- It is not intended for these added lines to live very long: One can add flags to AVFilter.flags_internal that indicate that this filter wants the inpads/outpads' names be freed generically. This will allow to remove most of the code for freeing in/outpads. These flags can also be used to make ff_insert_in/outpad free the name itself upon error. Furthermore, one can make ff_insert_pad() return AVERROR(ENOMEM) if the name of the pad that is about to be inserted is NULL; this allows to remove the checks for allocation failure from the callers. libavfilter/vf_signature.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index 5ea55d5247..d09003746c 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -730,6 +730,8 @@ static av_cold void uninit(AVFilterContext *ctx) } av_freep(&sic->streamcontexts); } + for (unsigned i = 0; i < ctx->nb_inputs; i++) + av_freep(&ctx->input_pads[i].name); } static int config_output(AVFilterLink *outlink) 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 */ From patchwork Tue Aug 25 14:09:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21921 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 77CCC44B5EC for ; Tue, 25 Aug 2020 17:17:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C03968AC1E; Tue, 25 Aug 2020 17:17:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 304FD68ABC3 for ; Tue, 25 Aug 2020 17:17:25 +0300 (EEST) Received: by mail-ed1-f65.google.com with SMTP id l63so8347865edl.9 for ; Tue, 25 Aug 2020 07:17:25 -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=PX6zlZXigW99uy6lk33afbTh54z0d6K2G3o6Zovwk/g=; b=JtMcN8ajYzpbWI+A+3kjZQut1KdABGuJKX8L9bFN9A1jgFyU5apiYMjezAqokxJkSK XnbgZND8FOb47qlyBZN54l3/bD5cUbbWbEnPPr9QR6cKJJbgj41L2nepPNvwNg6BiGgg svwpTADw/6WuYjZwNHJYuKzv5juqw/FoCC6YhWjmA5tSghYlFjuiYiTpX/QL50gG3bBt /1klSmpEBGMSNpzBUh1gnzBUYQJCVdgZIa5K42vv1YZ/bLvkTRpKdfoRFQdVsA4xCXSt +udCP4vxfZZT/kjXcJRHQZ+ZVpFrcNU2D5NbrIqTX/auHYbZThl2HfVBPZ8Sp5pSkIIu ufsQ== 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=PX6zlZXigW99uy6lk33afbTh54z0d6K2G3o6Zovwk/g=; b=d6gMEro5dBs0wHaEcIkG4MWDpnfmXctfyBoeQ7MzM6+ZU2TWlDXjCt4G5MxmUFyJi8 Odn8hE6JiAbBuH5L8A2KlHO4efp028aOF+EXu8acstXQAptUbYJLqMWZZO3kqPRU2p9W gFh+QbUV46zFnXMRdFLcNXlUzF0gJEIlXgxi+uiSCX7byZS8vq9QXtEuimqhg3Zf6Pkq 0EAybXm8B+S7MDMqAmdyuWrB467mSxTR8yMMu4fTnlPHGZWc88rIRAjZjP6w20FBoESW 5Z3aH7NpyvOJlOX91grWOTynYfutSyECUemyCtd450GW8uylkpVHKstTqx4AO9CwmoJp PjkQ== X-Gm-Message-State: AOAM533vCNRprtfbrMfqQIOgV6E6Vpxgz+rVoIFq9CV1MuKhY9FNo1/m /Yf2TM173usOUieYjEn9xY+xA+DHFjg= X-Google-Smtp-Source: ABdhPJxUJdYpT8bQXUhD6AWKuVhSoKcBZ5Ezi4q4wwK26jvjFOWO30T6OtxMbplvrgAatGxCO/WlYg== X-Received: by 2002:a50:ee0a:: with SMTP id g10mr10026503eds.289.1598364623299; Tue, 25 Aug 2020 07:10:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:22 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:25 +0200 Message-Id: <20200825140927.16433-17-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 17/19] avfilter/vf_signature: Avoid cast from function pointer to void* 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 signature filter uses qsort, but its compare function doesn't have the signature required of such a function; therefore it casts the function pointer to void. Yet this is wrong: C90 only guarantees that one can convert a pointer to any incomplete type or object type to void* and back with the result comparing equal to the original which makes pointers to void generic pointers to incomplete or object type. Yet C90 lacks a generic function pointer type. C99 additionally guarantees that a pointer to a function of one type may be converted to a pointer to a function of another type with the result and the original comparing equal when converting back. This makes any function pointer type a generic function pointer type. Yet even this does not make pointers to void generic function pointers. Both GCC and Clang emit warnings for this when in pedantic mode. This commit fixes this by modifying the compare function to comply with the expected signature. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_signature.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index 80957d0047..32a6405e14 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -132,8 +132,9 @@ static uint64_t get_block_sum(StreamContext *sc, uint64_t intpic[32][32], const return sum; } -static int cmp(const uint64_t *a, const uint64_t *b) +static int cmp(const void *x, const void *y) { + const uint64_t *a = x, *b = y; return *a < *b ? -1 : ( *a > *b ? 1 : 0 ); } @@ -291,7 +292,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) } /* get threshold */ - qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), (void*) cmp); + qsort(sortsignature, elemcat->elem_count, sizeof(uint64_t), cmp); th = sortsignature[(int) (elemcat->elem_count*0.333)]; /* ternarize */ @@ -317,7 +318,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) } /* confidence */ - qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), (void*) cmp); + qsort(conflist, DIFFELEM_SIZE, sizeof(uint64_t), cmp); fs->confidence = FFMIN(conflist[DIFFELEM_SIZE/2], 255); /* coarsesignature */ From patchwork Tue Aug 25 14:09:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21925 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 5D67244A992 for ; Tue, 25 Aug 2020 17:34:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36F7E68827C; Tue, 25 Aug 2020 17:34:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD5C66880C1 for ; Tue, 25 Aug 2020 17:34:45 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id q14so1829289wrn.9 for ; Tue, 25 Aug 2020 07:34: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=uzrk9Hgvx/DPjLdpRpHMlNM+qFt0Bvnuj2jARq5t74E=; b=o7c67EZPu8nNwiTp6X4VMX/ZxpuTvz47BkMlbuaUhAHeaFKooo+HE3pR69X8nlVq66 wk5vXMCbjW/3syVDYgLaKDt4z4Ac3/SrPomYTPe6bJtg1zu/lP4r4w4/X6PBc+FONERx 0euKXlRxg4ffeOuTPjgrMLwbA5Lso8aLMyod0OzkPVMgLe1Xs1+l74YK68TjTKtsUWvM hJeAixONAbnBYF9wmbWXXQz21hDlZRiPBexCFEytCaB9kG4CMpUqdQVHtFKGl7qWEtfk X76IiWms7okeUsW29WkQHEF/DCAqSfPs4Vs9z8r+YB+UQlm5BQ5RrXyE5xcKo8MAWReg rBgg== 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=uzrk9Hgvx/DPjLdpRpHMlNM+qFt0Bvnuj2jARq5t74E=; b=Mw9JjGYOzyOfVy/Fnsjojn1VYGG/+q5NDn3wA24jhlEQQ+NO6IhYoqC02NAH8pEJp7 +dGxhJD9gQwDGQvthXQxGm3uLTLJspTMVQcFbT4aBUse06gXlyOyYcl12iIl9WpnGSgS 8Y+QgArqFJPfuMthYrs1aBFow9PBclCpBrbBXvtLgcKsKQxfLzdlzci7xrNeD1fXo5j4 Vrtg1vuHvkk33JwsQjqEPUA4zLqwia7GHEmAI/fy5XPer2lP96OaEEkcmK722+VlIB+J qr3a0FJMY/yW3DiLWMya0KgsEc4ewcmdpZ6Ufuu9Z89bI18U29X9luv3EcVB7NCWqBYR 7x+Q== X-Gm-Message-State: AOAM530FHnL/h7DeVyP54sVyKCFPaQtTu8zlwdgt4093qCeAsRlxMW35 VUKLTXksvGDARb8eX9XAh4KkjXLjTeQ= X-Google-Smtp-Source: ABdhPJy9/pHNt53QnSQWt8WInUf7wBSNybrKeryT0lsuwx8dAuP3Hs2fKHBBPGws19VOmVIPCrfaEg== X-Received: by 2002:aa7:c6ca:: with SMTP id b10mr2239309eds.269.1598364624396; Tue, 25 Aug 2020 07:10:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:23 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:26 +0200 Message-Id: <20200825140927.16433-18-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 18/19] avfilter/vf_signature: Allocate arrays together 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" Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_signature.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index 32a6405e14..1ed93051b6 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -257,14 +257,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) int64_t* elemsignature; uint64_t* sortsignature; - elemsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t)); + elemsignature = av_malloc_array(elemcat->elem_count, 2 * sizeof(int64_t)); if (!elemsignature) return AVERROR(ENOMEM); - sortsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t)); - if (!sortsignature) { - av_freep(&elemsignature); - return AVERROR(ENOMEM); - } + sortsignature = (uint64_t *)(elemsignature + elemcat->elem_count); for (j = 0; j < elemcat->elem_count; j++) { blocksum = 0; @@ -314,7 +310,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) f++; } av_freep(&elemsignature); - av_freep(&sortsignature); } /* confidence */ From patchwork Tue Aug 25 14:09:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21919 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 9060644B6CA for ; Tue, 25 Aug 2020 17:10:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7980368AE6E; Tue, 25 Aug 2020 17:10:34 +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 4353068AFA5 for ; Tue, 25 Aug 2020 17:10:27 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id b17so8444836ejq.8 for ; Tue, 25 Aug 2020 07:10:27 -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=506TWpTewRdXloEUJj7dXScmI+Ek7tTZH0uAtzdODGg=; b=CYCfRaUAlnvDUpdV3cf8iu68xGXDc13WZKUvv+hDozSlJ3yQKN+Eq6T+NASSCdAdx7 lMjUDXwJ1ZedCmEmw9N5FIHdypYrefEutBDw3zgKWdiZJbfJlA5oQ9Z+lv39Y3SuxQm8 fMpRznU2qer6cSr5EbcWfB17dQl8Jwp0OYTLvMn/KrAUhsgjP7vK6SKs3PoMc6J/VXtD Vd5bGusuLHiv3X5dTzGyS/RY7Gd6SU+M7dgoEpYbRGTDJF2NLTi5gXJfCAOtxrWMNm1T 19tQJcBKLJAP+OQT0DTdzaUdwaKKDZsrjgmXxNq1JLXOYCeKuqtitlg98/xD9HPFnC8H gW2g== 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=506TWpTewRdXloEUJj7dXScmI+Ek7tTZH0uAtzdODGg=; b=HLozNbBw67DDaLFvijmQz7kz+k54GPqvd9RhQJVV1rwd5oUaHkr/e2/ozyep+uvaq8 aTsBgwBkAjZiP41WLb2ljAaP/V20dLmlDHUTixuCG9UNv5DzZHz4Q/LUKpSyPJqeNXQa uDwE2S/O87PqHpMk65ax+zrHcTbywu6OxeajyZ0QZppPkKaIbisS85KbUtxgxDHapNkm oeQ5qzsWZ+vCDCCti+06SNQCgi9Bs0D8SvjsUhdXzfiesLPnrX+b7RoxpYaegXAYjBtR VLJJ+uKFTTwXvEJUtEmy2fLJe5YqF7rdtA1hDY1zRQBzEwHxIP7bMNBdEeDtlAoLWGnV eLWw== X-Gm-Message-State: AOAM533/L/kRWZNCVI+susXtQsAjrUXEltDSX5AmrvYpe/NreTZkxjTN dTdKVGwgc9V50TSjO2tip4fw3qeR+Z0= X-Google-Smtp-Source: ABdhPJxVw77sMAUCXn3E1v1cB/RNtSZdnEsNWZYqvgQUhups+Q5YA04NxQBij2epMl51ESBYrCWHlA== X-Received: by 2002:a17:906:5f8d:: with SMTP id a13mr10492617eju.226.1598364626235; Tue, 25 Aug 2020 07:10:26 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 07:10:25 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Aug 2020 16:09:27 +0200 Message-Id: <20200825140927.16433-19-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 19/19] avfilter/af_headphone: Fix segfault upon allocation failure 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 headphone filter uses a variable number of inpads and allocates them in its init function; if all goes well, the number of inpads coincides with a number stored in the filter's private context. Yet if allocating a subsequent inpad fails, the uninit function nevertheless uses the number stored in the private context to determine the number of inpads to free and not the AVFilterContext's nb_inputs. This will lead to an access beyond the end of the allocated AVFilterContext.input_pads array and an invalid free. Signed-off-by: Andreas Rheinhardt --- This is not the only thing wrong in this filter. Will send a separate patchset for it. libavfilter/af_headphone.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index 552ad84837..751f4ab53d 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -812,7 +812,6 @@ static int config_output(AVFilterLink *outlink) static av_cold void uninit(AVFilterContext *ctx) { HeadphoneContext *s = ctx->priv; - int i; av_fft_end(s->ifft[0]); av_fft_end(s->ifft[1]); @@ -834,11 +833,9 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&s->data_hrtf[1]); av_freep(&s->fdsp); - for (i = 0; i < s->nb_inputs; i++) { - if (ctx->input_pads && i) - av_freep(&ctx->input_pads[i].name); - } av_freep(&s->in); + for (unsigned i = 1; i < ctx->nb_inputs; i++) + av_freep(&ctx->input_pads[i].name); } #define OFFSET(x) offsetof(HeadphoneContext, x) 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);