From patchwork Sat Aug 22 23:04:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21822 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 7C421449E7C for ; Sun, 23 Aug 2020 02:04:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 592F068B5F6; Sun, 23 Aug 2020 02:04:50 +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 AFDA6688057 for ; Sun, 23 Aug 2020 02:04:43 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id l2so1375245eji.3 for ; Sat, 22 Aug 2020 16:04:43 -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=GH75npHNmr5W71YmBSrNmsLnTOaXUT4zgpHt/JZYfkA=; b=coopIT40p43NUqJcLr9Su728EzJuILRAlX3ett6d3XDcfR/7lLJHcoULPtCLpe9GDN IgFxiIpOMjGSnhj5ggAgt/01YtDvNUnEgmg5rTayu5ZNTMqMCbLzjoQw4bO8Waz2TICA XScibRekbed7ngbf5XxkL2Zde9ToijmRXgD8EdswYSl6zZMPPkGE0ewGhGHL1NMlIO12 TTjKRowSlDGBPlKrn5O/Ab/hvGut5X7ZVnuYO4vKsgH79XxmIKllGlxyetmhM7BcFIuI E8+eh080mb5h2Hw9I1hC4rIJOOaxkJ8WzeW/puGf9bac0C2FrhvwOKWtqY0xsQtIYCAZ 0plQ== 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=GH75npHNmr5W71YmBSrNmsLnTOaXUT4zgpHt/JZYfkA=; b=OHuIP1dVtFkpRd3IUwGEyn5WdNke6Q3OsurAKVeTR+u/0hMkdGVgPt8TXOuj1wv8GZ f0dpV4WRwB01Az7vRqgjdMouUpYUxS/k35DFT9ucj6m+Zp+BdGMqPja6Lc1bXAaokWoq YPj/zBlJcpOfIejRfj+/rQM0eRqM/YropjY9DkBE8zsnf3F6cQuD5PpDPka9BfOCl957 6PU+9a6oO8X3kahAN5Ycca1GBJH9Tu3V3FzLIEie4CiDqeys6UtRwdfBl5cNx7JmcfJE +sPC8S8s7ZEx1d5ld/Ao0NKMARc90Ma71Q7Ec7IdnDLo3mggMkKX4UnY/59lu8tpyEeS fS/Q== X-Gm-Message-State: AOAM532s6bTfn04uQHxbx+TbJJH1PM38ngl1R9FqblNkbQhioxQjCizB ZpYAVrFZ2gxu/28kDnfYuFPKPEM+qpc= X-Google-Smtp-Source: ABdhPJw8CYiDgctAs8opVh4yls62FRsVWMgXyBmOYxLtjKnSadp09GYc2/SNrc3H4NhwaXr4OYB/sA== X-Received: by 2002:a17:906:150b:: with SMTP id b11mr9019325ejd.234.1598137482677; Sat, 22 Aug 2020 16:04:42 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id d24sm3813366edz.77.2020.08.22.16.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2020 16:04:42 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 23 Aug 2020 01:04:32 +0200 Message-Id: <20200822230434.11347-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/graphparser: Fix leaks when parsing inputs 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" parse_inputs() uses a temporary linked list to parse the labeled inputs of a filter; said linked list owns its elements (and their names). On success, the list of unlabeled inputs is appened to the end of the list of labeled inputs and the new list is returned; yet on failures, nothing frees the already existing elements of the temporary linked list, leading to a leak. This can be triggered by e.g. using '-vf [v][' in the FFmpeg command-line tool. This leak seems to exist since 4e781c25b7b1955d1a9a0b0771c3ce1acb0957bd. Signed-off-by: Andreas Rheinhardt --- libavfilter/graphparser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index d92b5360a6..dfb94788e1 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -303,8 +303,10 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, char *name = parse_link_name(buf, log_ctx); AVFilterInOut *match; - if (!name) + if (!name) { + avfilter_inout_free(&parsed_inputs); return AVERROR(EINVAL); + } /* First check if the label is not in the open_outputs list */ match = extract_inout(name, open_outputs); @@ -314,6 +316,7 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, } else { /* Not in the list, so add it as an input */ if (!(match = av_mallocz(sizeof(AVFilterInOut)))) { + avfilter_inout_free(&parsed_inputs); av_free(name); return AVERROR(ENOMEM); }