From patchwork Fri Jul 26 12:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13742729 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (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 98B60A3D for ; Fri, 26 Jul 2024 12:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721996111; cv=none; b=TdZEFrOEXwzPFrWlCbzgkzkt2GHfyH2A/glmBXaW9p8cc/zY7M+vrIyY5MsFQV8mZpN4wWTJPJQ/5PnQhelnpfhWVr77YFCeh+449AbcP18fX+QuVOkKx4+WOFRsRiTbUa+IEisuVBG5b+23hc+Ytvn3gLQwai84AfEsq04royY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721996111; c=relaxed/simple; bh=VRXNDcGJ4HWe6YpfCm8xFsjceQTMYKgLp6F2Q1PbZOk=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HKlYl+pg5FQAQM0G8ZrT2z1gZlnFL7lVXVg/NQsXbNV94eGvDzfsPFAyxf1NQP1I4+7UgZbf26X+szhInoc+C1ZkPWAfAWXM4wcE2ZU+xWtPFzyUyFUtkSfFmsSU0m6QmFXC1SEkdC3B+bmglx9Y6y/AdmL3dp9/yZAnGqUo0XI= 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=fGXwInUN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=g/H54iRb; arc=none smtp.client-ip=103.168.172.148 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="fGXwInUN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g/H54iRb" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 74BBE1380532 for ; Fri, 26 Jul 2024 08:15:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 26 Jul 2024 08:15:08 -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=1721996108; x=1722082508; bh=/xVE2Lesc+ A1JM41zcuE8UgGg+Y6uhpj1DZmanjNan0=; b=fGXwInUNhuSwcnFdL9/2QYyVmu L4Hc4949y2xe7ETxNzQTWKgEU1az8l8j9na/a1vorpnvHqIl28IkwEnBkRtGJONW FLzztsN3EqUkYN0WrLDUida68tJfwOysQU8ivTQbxP6hhR1IlygZMgpF4QHh94Y4 imJzE+nm6jf6r3YbzfyPPEBLJ73C1k4HW74l0hla5OBXfIue7MFvojqvgnWhqcGQ QxxgV+6GR8RDANA4f52kV8wyVvPwWYswmV4AHf4p++ffdeW0KIdPMeBXq+/QO5cF TB2Mkl18CVE86zb6lX4tUV37V56U63yzSjERpEiYSJC4nLT8+JAhQ9Yfltow== 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=1721996108; x=1722082508; bh=/xVE2Lesc+A1JM41zcuE8UgGg+Y6 uhpj1DZmanjNan0=; b=g/H54iRbuXxzLM1eLqwHkVedXPgiO5DgK+5VRyGCTxdq jXp/9+aDZGOdKZ5eM7otF34vv3GaSxyzmOBU3Cii8u//i+Jg3QMq2CJgX00q4n50 CawdpOAOg9NNf+ur6NHtReQCagkax2bOdcRwVbEK1cqhWzfsAVSJ2et5iKvVNo/P /ZmiujwwOntmWYzjYfSfmwioWUmfwkDLLx/kLBsyr8fQRfkwXP+ZvEUo2XwCZMwd uMWwbanOKxrOKKd555Z7Ri6jMEb0Uj2tbeXbvnamZXGlCARdhHsJFWoObn7M1bwB Ph6HDLtJYAIWSLZtJH1Ml9a78vFFh9a+R8i32CaRDA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrieehgdehudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 26 Jul 2024 08:15:07 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 37a551b4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 26 Jul 2024 12:13:45 +0000 (UTC) Date: Fri, 26 Jul 2024 14:14:55 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 06/23] builtin/name-rev: fix various trivial memory leaks Message-ID: <088f730572f0f5aaa8f9640ea35a4687be9094ba.1721995576.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: There are several structures that we don't release after `cmd_name_rev()` is done. Plug those leaks. Signed-off-by: Patrick Steinhardt --- builtin/name-rev.c | 6 ++++-- t/t6007-rev-list-cherry-pick-file.sh | 1 + t/t6120-describe.sh | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 70e9ec4e47..f62c0a36cb 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -677,7 +677,9 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) always, allow_undefined, data.name_only); } - UNLEAK(string_pool); - UNLEAK(revs); + string_list_clear(&data.ref_filters, 0); + string_list_clear(&data.exclude_filters, 0); + mem_pool_discard(&string_pool, 0); + object_array_clear(&revs); return 0; } diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index 6f3e543977..2d337d7287 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -5,6 +5,7 @@ test_description='test git rev-list --cherry-pick -- file' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # A---B---D---F diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 79e0f19deb..05ed2510d9 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -14,6 +14,7 @@ test_description='test describe' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_describe () {