From patchwork Thu May 23 12:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13671722 Received: from wfhigh5-smtp.messagingengine.com (wfhigh5-smtp.messagingengine.com [64.147.123.156]) (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 999F613D61E for ; Thu, 23 May 2024 12:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.156 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467189; cv=none; b=WpuwrTreH7qBBMgi1kl26l+u5TlgQLiBDF+3C1N4MUfE4ns0SxFDUsrd5XWy4vP4cFc9gsnPI3VcmmS/1lOmRkcyNmdflKAhHO5qhuQ99bDJw4nkw6w5y65ifFiau/5TQrmx4aeViuglyi/ncQSdwtxa8wLcnjJaTvg2yKCTkKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716467189; c=relaxed/simple; bh=ATvhDk7HoD70R21giR7+aUllzJrHsDaiYjlFOwcjIeE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bncWSedVTUA5edzAGdSHFiK96JgYKnBptR9sPIwDgs7IJB1OXg6Gh9o+OXH43L0xeyHBTAyVqYV5NnjblBALqBPH8SdsXBbaQqXFBdRoELuXJEBwVHRG/K8oCBlKa1vauHMWHexHPRsFgrym/IPdplVmNpEULNRIeJ9AtE1nn98= 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=BK/4hJTh; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=SXjDQUN0; arc=none smtp.client-ip=64.147.123.156 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="BK/4hJTh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SXjDQUN0" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 1314D1800103 for ; Thu, 23 May 2024 08:26:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 23 May 2024 08:26:27 -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=fm1; t=1716467186; x=1716553586; bh=rWfiPUyHXj KAB04rbYqQdWTDIyX0gwZ0p6xqr121A7c=; b=BK/4hJTh+ZtjxO1coul4QFqCkI Au1N65+ykwD1nNPFc373odUOYnLos7T5jCTMeILwQP0TM08EZpxoi4NI4NgRxKyT PP8EG9TxERL/6puI1vz5grn+6KHgwr+jRrDq8kXfgGwPahl4lC2K9mgnwHRqgwmE febFxwSGqxOkoTkXqzOKlWnIteg/EV0GQPcJa1Kklvzthb9IMtgAK/ZcTTdh0DTt 4M5/CtMeaSQYU20dbRI6wEAPTkvzPH/hzClpsYzYecHDPVG0p4LI2O2B6nVdDwsP bKF1TsKn4910r2nHDsEUc0VKTpJqjmA/oteg3LqdyuUzpYnIDcumvMmnoj+w== 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= fm1; t=1716467186; x=1716553586; bh=rWfiPUyHXjKAB04rbYqQdWTDIyX0 gwZ0p6xqr121A7c=; b=SXjDQUN0OA9QAlYyDdlVaqxUQ9tGWMvmLhBYHeO9uhlg cMP92M3Ect0RGR0WXO1YTCvnE7nz5aSFj9S2xypygtXrbB9VOvCB8PrxLaTios1y RSq51OA4uCCVkRHJA3ZIc8svGwaVqZgdkh+NenFtwc9DjMgNqr/LzOwkJ6YShi6S aMOmG/fxq3378yne9v+NAbktZTIKn1pMJ4SFnuTsqI68QYhoieY/DEHh4I1+o63Z gLc0kGeeRriftc+xzXiGtlA3TUa6vxqoOAqx5Rg/BfG2YFEbij8m3N9a+wr/wv5r yNDbrJbphIL4tkbYNeZnsiHDNyMIRtCv63NDp136IQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeiiedghedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepvdenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 23 May 2024 08:26:26 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 78ae7500 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 23 May 2024 12:26:19 +0000 (UTC) Date: Thu, 23 May 2024 14:26:23 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 15/20] submodule: fix leaking memory for submodule entries Message-ID: <24362604b2390d69a58c2064d9da0fe248070d46.1716465556.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: In `free_one_config()` we never end up freeing the `url` and `ignore` fields and thus leak memory. Fix those leaks and mark now-passing tests as leak free. Signed-off-by: Patrick Steinhardt --- submodule-config.c | 2 ++ t/t1013-read-tree-submodule.sh | 1 + t/t2013-checkout-submodule.sh | 1 + t/t3007-ls-files-recurse-submodules.sh | 1 + t/t7112-reset-submodule.sh | 1 + 5 files changed, 6 insertions(+) diff --git a/submodule-config.c b/submodule-config.c index 11428b4ada..ec45ea67b9 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -91,6 +91,8 @@ static void free_one_config(struct submodule_entry *entry) free((void *) entry->config->path); free((void *) entry->config->name); free((void *) entry->config->branch); + free((void *) entry->config->url); + free((void *) entry->config->ignore); free((void *) entry->config->update_strategy.command); free(entry->config); } diff --git a/t/t1013-read-tree-submodule.sh b/t/t1013-read-tree-submodule.sh index bfc90d4cf2..cf8b94ebed 100755 --- a/t/t1013-read-tree-submodule.sh +++ b/t/t1013-read-tree-submodule.sh @@ -2,6 +2,7 @@ test_description='read-tree can handle submodules' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh index b2bdd1fcb4..3c1d663d94 100755 --- a/t/t2013-checkout-submodule.sh +++ b/t/t2013-checkout-submodule.sh @@ -2,6 +2,7 @@ test_description='checkout can handle submodules' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh index 61771eec83..f04bdc8c78 100755 --- a/t/t3007-ls-files-recurse-submodules.sh +++ b/t/t3007-ls-files-recurse-submodules.sh @@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly lists files from submodules. ' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup directory structure and submodules' ' diff --git a/t/t7112-reset-submodule.sh b/t/t7112-reset-submodule.sh index a3e2413bc3..b0d3d93b0b 100755 --- a/t/t7112-reset-submodule.sh +++ b/t/t7112-reset-submodule.sh @@ -2,6 +2,7 @@ test_description='reset can handle submodules' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh