From patchwork Tue Aug 6 09:01:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13754592 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 142A515F409 for ; Tue, 6 Aug 2024 09:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934878; cv=none; b=rxSI+RwCEPGnBSuwpetnTsPdQi/Mx7wF/jOMauCbmfNVPbn23JxRI9DaIW1mYeRbr1MFfN2XIa8lvP+33slrmzrKfL4RV0m/sGPLAqhjoWP8oSIuZqSJHIXMEcFE7minm0fr4sKNi5UwTZZIE0ztz1l6qMY/m5910E1p7ZCDwK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934878; c=relaxed/simple; bh=+Z1/Un/qWq/yY3MzCUrqELTGcS/ZhrBHLmrjtLY8Y/Q=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RsLGVN6ZzIKRoTb9e10ITipC1pzcUNzEmnZ5SuVzFP/J7RIiYWaSKeNHIPZL6e/WGA4P1ivRSEGzD7vbEkuAejwuxk4ZZHbD/wZ1aVdB4TcVDnNOtXhQQxO3ob+ePpcXzAbyajOq1A6Bzj8fsreqREIx/FBJc7DxuQquk37aC4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=eg8royJw; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eW7igtmC; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="eg8royJw"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eW7igtmC" Received: from compute8.internal (compute8.nyi.internal [10.202.2.227]) by mailfout.nyi.internal (Postfix) with ESMTP id 3B49F138FCB9 for ; Tue, 6 Aug 2024 05:01:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute8.internal (MEProxy); Tue, 06 Aug 2024 05:01:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1722934876; x=1723021276; bh=RWNd7SS+Wc MyL7Wn/s3EMCGlw9FhIRXCsH2fN1yMvUA=; b=eg8royJw1aOVNIlInUkLOO24Fa 6w3cwskesP/dXeZhTkLV8brtIuokVOAoaez7FTrGNGFtn7rlsDXACofaz4By3Cyj htCiQ9V1MhhMCbQn6A4w+r5mQLRfgl4fiTlLiHXoPMpx4fbSnh46s8HDMt8UuR05 a0ucdozGhVeuFZLBap7J5/scH9Qy9YVMowUhmBodtjOcYX9ov2LaUZX4bNtyH3T3 i0vIfCXqVuYWic36r42BJVwPoPPI9FSF3XpgN5bvcvxTYvfiIuwN0ZLjZkczUuKd Yza5O132nL7HKAzovW0mgcVRnoHaExVuP3Xh64Z/MAUohnpDf2t0PU5Bp3SA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722934876; x=1723021276; bh=RWNd7SS+WcMyL7Wn/s3EMCGlw9Fh IRXCsH2fN1yMvUA=; b=eW7igtmCP97ky5Y+DOtWrRcdLoG92PSUTxMBP6QsWTv5 dZykoOj/n8hWCpidSKMhCto5k+ZtGseS3xJ8VVr12+qCU/owF3VwCTzmG8fqV9n0 QpkbZRpuSs6D4UT9wfSkALRjlKLRXS0zOzBLmBSrwc6pUtq93Yb4ssOPI0KnuYRa cDpeZ8kxz0YtOCm8OpARsg3G6r9XcsxwIgs9jXQTSGY2psuOAB8legpKCbW1Qi+0 P4kpDXWccXfjDDHsje/K0C6dZBf9+YcmuRur/Ab43JMzezqdVfrB84yahjugfuh/ NdDRCzf7EE6HWROdYCgQTC+u5jYzVQk0F7eKvK1EOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrkeekgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpeehnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 6 Aug 2024 05:01:15 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id dd1e3e92 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 6 Aug 2024 09:01:13 +0000 (UTC) Date: Tue, 6 Aug 2024 11:01:13 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 21/22] diff: free state populated via options Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `objfind` and `anchors` members of `struct diff_options` are populated via option parsing, but are never freed in `diff_free()`. Fix this to plug those memory leaks. Signed-off-by: Patrick Steinhardt --- diff.c | 10 ++++++++++ t/t4064-diff-oidfind.sh | 2 ++ t/t4065-diff-anchored.sh | 1 + t/t4069-remerge-diff.sh | 1 + 4 files changed, 14 insertions(+) diff --git a/diff.c b/diff.c index 9251c47b72..4035a9374d 100644 --- a/diff.c +++ b/diff.c @@ -6717,6 +6717,16 @@ void diff_free(struct diff_options *options) if (options->no_free) return; + if (options->objfind) { + oidset_clear(options->objfind); + FREE_AND_NULL(options->objfind); + } + + for (size_t i = 0; i < options->anchors_nr; i++) + free(options->anchors[i]); + FREE_AND_NULL(options->anchors); + options->anchors_nr = options->anchors_alloc = 0; + diff_free_file(options); diff_free_ignore_regex(options); clear_pathspec(&options->pathspec); diff --git a/t/t4064-diff-oidfind.sh b/t/t4064-diff-oidfind.sh index 6d8c8986fc..846f285f77 100755 --- a/t/t4064-diff-oidfind.sh +++ b/t/t4064-diff-oidfind.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test finding specific blobs in the revision walking' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup ' ' diff --git a/t/t4065-diff-anchored.sh b/t/t4065-diff-anchored.sh index b3f510f040..647537c12e 100755 --- a/t/t4065-diff-anchored.sh +++ b/t/t4065-diff-anchored.sh @@ -2,6 +2,7 @@ test_description='anchored diff algorithm' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success '--anchored' ' diff --git a/t/t4069-remerge-diff.sh b/t/t4069-remerge-diff.sh index 07323ebafe..888714bbd3 100755 --- a/t/t4069-remerge-diff.sh +++ b/t/t4069-remerge-diff.sh @@ -2,6 +2,7 @@ test_description='remerge-diff handling' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # This test is ort-specific