From patchwork Tue Aug 13 09:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13761649 Received: from fout3-smtp.messagingengine.com (fout3-smtp.messagingengine.com [103.168.172.146]) (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 C018518950A for ; Tue, 13 Aug 2024 09:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723541479; cv=none; b=p5+SreC8sAQXdQ/j0Fuhyaz3T9OL54ALIbL7lHh6yTGzvI+peZusBDv5ThNItj2WSQtSpph+fjUs8v133Maj+YxIy3wm0FE1dQNoyIvKBo9on4bdDsRbWczEupt1Q9kO9Cu1q5pdN/obUSc74kPXNQmQBOOLuzy7ziuLJWBfydE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723541479; c=relaxed/simple; bh=luZlTz2hTI8YLT4pNO5tz0if96yQMyYh73CZ46a0rCk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hVkMPPreCSbNE91HJreeg3qbtHpnRqWO2FIRojt1n5nHkOsslZ2zsaSXzC2UviURGzT9n/75+sPE4mUtqnref9VfiBjO+3klrARhX9I+WmQ3wdFfLRwll+Ra5ppEk9P81ljbPzPGumqgzZHaEVGE0/MWqbCofiECaRCGNmbi8Hw= 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=MCtk8QGP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BpVceFSj; arc=none smtp.client-ip=103.168.172.146 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="MCtk8QGP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BpVceFSj" Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id CD366138A055; Tue, 13 Aug 2024 05:31:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 13 Aug 2024 05:31:16 -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=1723541476; x=1723627876; bh=vAJymv3/2V GXDhjMfmXOqsXr79Vg5+j45QHKvwZBsks=; b=MCtk8QGPS9EeJIF9xNV+Qv0YX6 pkzj3byRAdGDkVuwvff6E4SxVJALsGXSeAF3f3OsPU/kBf1naJ/PaUZeIN14R11X 3+v27iDfoGEHx5YE0w3tThtLnRGdQsfpWVc/HbgXv7zQekXSv8Ti3yTXUE3wm4fi sqgXeESSENQ08oaWJpLVYcx6Wh2ou9kLKoSGSA+wkaXXqHJ62U4OfxjtJT2K1k75 Mg08aEvlP2zUHggb+agb16Bt8qwQwduouWlHWWtOK5zhoGcSShsOdQbIdUSutmOc n4vbpTRuqEH7BrsHEthlYy0Zo1ZSuUctEuXCcAvctCRWUCQPg0RuwtQ89PHA== 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=1723541476; x=1723627876; bh=vAJymv3/2VGXDhjMfmXOqsXr79Vg 5+j45QHKvwZBsks=; b=BpVceFSjaycB2Z2UK8aCYSZ+PttS4v/wqOzgk8gEDNlU 0DVpIwrbmdK2QyoMS4NibIX33m6AdqNqToyBspQZ1pu7GluzWF04dA3LcwTaRyAY oSx0AxAJVQXcCOosoY7uu83NeH17V8o0YGajjnY6QpL1jCjwx5K+Bc7Jq8PoDMwh X5TbVjyx1CzpveguE9einadEO5chZKYiLQnMmEiQZlFQvQl950085eLSlzDL/RsW KhJkhZSXl/skLq0pxU4v5SynI7Uvx+HXwJUoaONMZ9qCRC4a8tfeELhpnLl0TsPC 3ysf3e6T/0oiV2YrWgfDFfiG0BwJZav4o8nP7LF/WQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtvddgudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvden ucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimh eqnecuggftrfgrthhtvghrnhepveekkeffhfeitdeludeigfejtdetvdelvdduhefgueeg udfghfeukefhjedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspghrtghpthhtohepiedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepjhgrmhgvshesjhgrmhgvshhlihhurdhiohdprhgtph htthhopehphhhilhhlihhprdifohhougduvdefsehgmhgrihhlrdgtohhmpdhrtghpthht ohepghhithhsthgvrhesphhosghogidrtghomhdprhgtphhtthhopehgihhtsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhgvsehtthgrhihlohhrrhdrtghomhdp rhgtphhtthhopehkrghrthhhihhkrddukeeksehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Aug 2024 05:31:15 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id b0193331 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 13 Aug 2024 09:30:59 +0000 (UTC) Date: Tue, 13 Aug 2024 11:31:14 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: James Liu , karthik nayak , Phillip Wood , Junio C Hamano , Taylor Blau Subject: [PATCH v3 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 () {