From patchwork Thu Aug 8 13:06:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13757447 Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (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 9300018DF84 for ; Thu, 8 Aug 2024 13:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122377; cv=none; b=P6Y9GqUDeCpMCUQO+LDoMfNxGnoLkDJuOdNSXNCrw7XQVn0zoIzqAOJgryZqYGh1UDPWvaRzZ1iZdPvkM4/e8781/7ZUm2JgzDRPE69RDDMibGD8+Z310JFZRiV3FMFiVYGMbF4AoeY1LCGipDvRMb+tcabMofb+YwXPrtXQv+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122377; c=relaxed/simple; bh=GIlxa1HODxkm3hV8nIa7Dtqbo7cbrCwwnRK+XbQETh4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rQgQZjLH6QwBMAvrm3oBq7Q5fo9bjHKbmcJ5J4nYJgA+jHsbSvvgLxHM4r36vtgq9g2BONpagoLDKBEWkepaId6ytdgONYhAVW5ZNWouwe4symZxHlydT9fDLQGoqq272RI0EkKdb4+eFF1fs4gYwgP3qrWF3aRxOz0LUe0PaNI= 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=iaTJsETU; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=r2VXH4ZP; arc=none smtp.client-ip=103.168.172.150 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="iaTJsETU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="r2VXH4ZP" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id EDD26138FC83; Thu, 8 Aug 2024 09:06:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 08 Aug 2024 09:06:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc: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=1723122374; x=1723208774; bh=bj+vfxISpE cIZwT0dec/TuA4lSrpWQ3tkTj/ADbEMlA=; b=iaTJsETU+K9Iz6ERjhI8gi+sTz FEzOeuACNpfEvSrwb4NTM4kG2g0C5kuZi0gIGnvOs59tlWrH12cndAfd7DpWuj9i NORIf/0vQZw4pDp2sv0WKXbHf6acfTAJO0MNcyfMNhT/XvE9gCtGQy9y3ngt6wWs M1ZhSDA8VbIqmTQnQC8UEgt8rSQqoUGimrs/MqrjS+ej3oPy5eXqJ/wATj1PEosw mr2hBHOp/asiNsExa/HMh9cuHP9F9RfYG7UdKPihvOVzGoOamR5GZ0qL25+EszTp ZJytrl7LJlj44InvczgoBuh7uIPA9Pmhx+t0wS0ROvrnLodgCy2hX0n1WtZQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1723122374; x=1723208774; bh=bj+vfxISpEcIZwT0dec/TuA4lSrp WQ3tkTj/ADbEMlA=; b=r2VXH4ZPRX0+FoUNC9844ZeRaolR//KTi07SDKuzUBcc 5BfOj70v15mjxEvljZQ4M2AXOKxZtBoUGD/EEbMAFGY4GSDyUy7t5JrrhWPK1g9C PFmYGFAAC3G8IR+j8IZ053ZZGd5UMdQ0BF3+/iF/2rncNj1dVWe+pV79jR4iQJjA hrIxh07OC6Lf8wuZlwKUC2+Snn1oTVI2hHgdC44Dxvq/qAV8rp0oK9UrtHYp2mAL g9p+T9BHilbYboqoQkoX1P0B8dHXIU3GVi9wO9BOy3u4YSgqYL3SJNzaUJ1AmdHv GObl/v+R6pCYEIQEiUYIcKDKYXe54uvVFNkEWX46tQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrledvgdeitdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecu hfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqe enucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeeh gfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehphhhilhhlihhprdifohhougduvdefsehgmhgrihhlrd gtohhmpdhrtghpthhtohepjhgrmhgvshesjhgrmhgvshhlihhurdhiohdprhgtphhtthho pehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Aug 2024 09:06:13 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id b0291d78 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 8 Aug 2024 13:06:07 +0000 (UTC) Date: Thu, 8 Aug 2024 15:06:12 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: James Liu , Phillip Wood Subject: [PATCH v2 21/22] diff: free state populated via options Message-ID: <245fc30afb4d9993381ecf53f8c081b17dde3539.1723121979.git.ps@pks.im> 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