From patchwork Tue Aug 6 08:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13754575 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 A66281BD508 for ; Tue, 6 Aug 2024 08:59:56 +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=1722934798; cv=none; b=XiuuhDczY/HUYF/ER6TNXfa2OrywKo45ANm8HROWQOBZekPHJixOSV91qTiURR5dtsUFeiCRzgBfZg3RpdZacJvRgC1na/rjm7x+2Usqhdab3pPAxB4BrdvdRPY2MdrInEst2QurUFslVTeg41U7TybBj+7d3L5stA4MsgV9Ef0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722934798; c=relaxed/simple; bh=PQ6HvMuClx2Wms+Z4AqCrqvyF7OwIPHYeMMP5EDPvMw=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=q6TTiorN4+FqWiZfhlzEGWSk80iGhvI4fVDeifr6vb3CDhQTvgpevuc0dfAiCv/P8+62H0HikZs+frxH8qKRzfzD3uEP+5MX3f5uQojJ6I2BKNiqlT41QpRbRb8B4vQxBIcK+/dBHx2GdPxVv1cW+lvtoFRv+ZCcmPBBIbcVYxw= 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=bGKd6UWS; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nHOKFmkF; 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="bGKd6UWS"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nHOKFmkF" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id CD0DE138FC93 for ; Tue, 6 Aug 2024 04:59:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 06 Aug 2024 04:59:55 -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=1722934795; x=1723021195; bh=ap73Do47Aa 9PhER5/lZPg7qzD5Kw8GgpmY26owWVa6Y=; b=bGKd6UWSYw+JhDJ+d4kdhqLFvn Cp0+u74bYY7fMPS14HJiTgivBSfkC+vyeYzWu0tlpcC7DnxS38356L4Oia37lxTL vBtQ/yw5ln7+ovfapy7/0S4R8y0mRerLHsMmFxDQRuOq/2oUlki6pY5GUgE9kK09 RY/pmcHchK3331o+sRT1QYGmK4shsJ1cuFyQkZkqlL0MEcvDVrGInf0kBNQRLSaT MXWV5RpNVUfHzuNiYsPzldcKEbWS4sGbtq0FqKHzwhFMw5f/n/KF/Zzgofix1gXX CQEXApF6ay3CHP6TIes0M5VMf3gFS4uuYtAlqQfe5M6+N9KYb6w/mSYxqLbg== 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=1722934795; x=1723021195; bh=ap73Do47Aa9PhER5/lZPg7qzD5Kw 8GgpmY26owWVa6Y=; b=nHOKFmkFXOfX1qE8Gn8d04oWaaqyoyaNw60JdOKwDunU rKS2nxl2Ef4RDVIQuCX+GJfmv20mbg6Ao96PiDKRJaMI8r6dEsRFXy0QpBZatZb/ ObHxZXvg4WLo5kOqBZdwC6/cVQ87J7V+2okVlw3otZMIQGDYi1QqPAejJRocjk1S Wzo8rkDNM0mmRGqaI39gz/UseP7YylKkFsJjhYqChzeRWF73VdS/60OprkCR+q6r 69OnopB/6mm19mX8AskInxZmj0IBnuaSlJDmVUXTSruXwDuZsiSayN4h6PxF/twD AixF3V5Kskg6JJX4n4VJalBhM5N4ltPc0ePFZ2jg7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrkeekgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehgtderre dttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhk shdrihhmqeenucggtffrrghtthgvrhhnpeehgefhtdefueffheekgfffudelffejtdfhvd ejkedthfehvdelgfetgfdvtedthfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 6 Aug 2024 04:59:55 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id abb9a06c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 6 Aug 2024 08:59:52 +0000 (UTC) Date: Tue, 6 Aug 2024 10:59:52 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 04/22] object-name: fix leaking symlink paths in object context 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 object context may be populated with symlink contents when reading a symlink, but the associated strbuf doesn't ever get released when releasing the object context, causing a memory leak. Plug it. Signed-off-by: Patrick Steinhardt --- object-name.c | 1 + t/t1006-cat-file.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/object-name.c b/object-name.c index 240a93e7ce..e39fa50e47 100644 --- a/object-name.c +++ b/object-name.c @@ -1765,6 +1765,7 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name) void object_context_release(struct object_context *ctx) { free(ctx->path); + strbuf_release(&ctx->symlink_path); } /* diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index ff9bf213aa..d36cd7c086 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -2,6 +2,7 @@ test_description='git cat-file' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_cmdmode_usage () {