From patchwork Sat Apr 13 03:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LuMingYin X-Patchwork-Id: 48037 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp654851pzb; Fri, 12 Apr 2024 20:57:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXdKl12Wxxo1z/MhMZmMC23Q2twWdilqkSXqjlMH48Al3B0osPsXQxUR1+x+btKXLSVDhrpQ4x3ICs1E70Do6MQU4x0MoJGdaFbsA== X-Google-Smtp-Source: AGHT+IHwrHjSXsYP5E+qWtwtoIs8zmwem9+BhFwcyBIHNGz3XLdszv9V0sMZ+7ofVzjvMG9kXvdv X-Received: by 2002:a17:906:4a8c:b0:a52:4091:fd0e with SMTP id x12-20020a1709064a8c00b00a524091fd0emr1129698eju.4.1712980645336; Fri, 12 Apr 2024 20:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712980645; cv=none; d=google.com; s=arc-20160816; b=NMw02Jix22wFZfPgpoo41lHy6VSrxNrLS0YD1EEr8B/qTpEYUaqqWoFcYzMaS6RnF8 Lz1EwKI8wyfL5wAwajWzJ71qQ0Qs5gZswpdQl8MmygttebxdkeS5ri5z4zPOmEu9KnBQ ClWw+2F6x1Ct0zHOnWkuGV5XoMa5GsM5qywLyIsI+u4C9uhIF437Vy91j2dtIuzXqSxW 6GvLz2UxPTHGqCzkZWxgKkS/H0daDWB9iMWpt/GXhFhVXcGvMF1z/o4Bb5fQC/6G0qzN 03cR7MjzAUp/NqYTggOOUF1losKv2LgV0C+TWxn6HlXkqO9fSs9ImWIB3ESd2QjdwWAK 4KoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=+ZDRJopoSqT7mm8Anl6EjTrApU4OgwcwwjclcQUj+Pc=; fh=h93Jk9zXtjyzsFd9PKvKbdVr/RKQn4bW7LGFE3/Lh8E=; b=vsmdLVqgVySsXTVu/kpNQ8EgD1Sgi2OQjG4JiKbJg6WGDFMxG4/niTAqH6OW1+wRkD f0BWbidDUoheZtaCsNuEgMaSjGJgcuBJBy5eN2XJlHrCow3Od5zel4XxAYPOPzt34hQl GxWoxGANOvERJrhMAygLqqutnFkZ9lXqg3LVoSJDEF1hxro8QnE3tXIxaek5JP6xiTOP MPuL4UwA5Q6OaLM+1wugL33rd3IapjcrUsIN0XQSxfGIS6etn4ZsmImct4191yNJZJnG RZJxD+FevZxHJe5aqN7ebzJ10O3Pwva+ODyNuMFyJGBiRB6uifa2wdp42642e8YP2YjH ysrg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com header.s=s110527 header.b=K9d+iWWg; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cw17-20020a170906c79100b00a51ae500831si2330118ejb.488.2024.04.12.20.57.24; Fri, 12 Apr 2024 20:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com header.s=s110527 header.b=K9d+iWWg; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADE6568D2E8; Sat, 13 Apr 2024 06:57:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B723468D292 for ; Sat, 13 Apr 2024 06:57:13 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=qt1u2 1C9c98VW6C0/9bTlCoTORl0kNG9sEbaCngexsQ=; b=K9d+iWWgA6NLnwGou/Phl pNDA9aTTmlxsYopdodN8LZBJLobCo71nqfuvEIYp1dlP3DSwy3Rt3vtg9ojteQ8t sxUTz7aURjDjOVCANVdavTkUcVx4ITvTTQX3eef25wvsbrS3C6/YQB8QfufLOAm0 Mg9n0/VtGE/4qcEeQuxGJQ= Received: from localhost.localdomain (unknown [111.198.54.11]) by gzga-smtp-mta-g0-5 (Coremail) with SMTP id _____wD3v2WOAhpmOHPuAw--.60471S2; Sat, 13 Apr 2024 11:57:03 +0800 (CST) From: LuMingYin To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Apr 2024 11:57:00 +0800 Message-Id: <20240413035700.1961642-1-lumingyindetect@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: _____wD3v2WOAhpmOHPuAw--.60471S2 X-Coremail-Antispam: 1Uf129KBjvPXoW8Zw4kCr4UAFy3tF4UJF1Dp5X_Gr13JoWUZF 45Ka48Gr92kFy3tF9rGF98Zw1fXFy7XF18CayUAF48A3WUKw1fX3WUZr4DCFs8Kry8A3y0 q39rJ3Z8tan7n29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3AaLa J3UbIYCTnIWIevJa73UjIFyTuYvj4RJgAzUUUUU X-Originating-IP: [111.198.54.11] X-CM-SenderInfo: poxpx0hj1l0vphwhu3i6rwjhhfrp/xtbBLxS-92XAkltU+QAAsy Subject: [FFmpeg-devel] [PATCH] libavfilter/vf_curves: fix a memory leak in libavfilter/vf_curves.c X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: lumingyindetect@163.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Fb2JUVLhVdBM The pointer variable 'point', which is defined and dynamically allocated memory within the while loop of the 'parse_points_str' function, is not released on error paths. Signed-off-by: LuMingYin --- libavfilter/vf_curves.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c index 3e4a42bab3..97f284db22 100644 --- a/libavfilter/vf_curves.c +++ b/libavfilter/vf_curves.c @@ -182,20 +182,22 @@ static int parse_points_str(AVFilterContext *ctx, struct keypoint **points, cons if (point->x < 0 || point->x > 1 || point->y < 0 || point->y > 1) { av_log(ctx, AV_LOG_ERROR, "Invalid key point coordinates (%f;%f), " "x and y must be in the [0;1] range.\n", point->x, point->y); + av_free(point); return AVERROR(EINVAL); } - if (!*points) - *points = point; if (last) { if ((int)(last->x * scale) >= (int)(point->x * scale)) { av_log(ctx, AV_LOG_ERROR, "Key point coordinates (%f;%f) " "and (%f;%f) are too close from each other or not " "strictly increasing on the x-axis\n", last->x, last->y, point->x, point->y); + av_free(point); return AVERROR(EINVAL); } last->next = point; } + if (!*points) + *points = point; last = point; }