From patchwork Wed Aug 14 06:52:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13762886 Received: from fout8-smtp.messagingengine.com (fout8-smtp.messagingengine.com [103.168.172.151]) (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 4AA2A13B585 for ; Wed, 14 Aug 2024 06:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723618325; cv=none; b=eEDrUzVcsGjjyUvbbCKapvHYUbzc1LNxxTdHxk04QhnNTRtXBh7pxzJ91O+1SWNX2eIkPYc78VUnRmQPikRBiW0egNjJDaJ8p/zVmNjr1Sw3Cd/tLHe8DrUAnlyykHU20/+ocSIf2wuHa9TljvmGqRrSkS+f3oq+wdHZLhKXR9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723618325; c=relaxed/simple; bh=luZlTz2hTI8YLT4pNO5tz0if96yQMyYh73CZ46a0rCk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Dj9KXv7ABcYAMv+l+L8kvHJuLPMVIlGrfMogOELKnJ/A9pMEx3iYT9A/iYq0mAByLrwh4UR/LWboUoJYDv7MXkO14talkJJHnUMzuU1TRDM9LFN9OCJjL4EcVcWHY0WX9qkahKKahXwp3xjgwqK9GrvD3XwuBMgVRlk1F+f+9e8= 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=MDAfaLcl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VuObgU35; arc=none smtp.client-ip=103.168.172.151 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="MDAfaLcl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VuObgU35" Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id A49581388210; Wed, 14 Aug 2024 02:52:03 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Wed, 14 Aug 2024 02:52:03 -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=1723618323; x=1723704723; bh=vAJymv3/2V GXDhjMfmXOqsXr79Vg5+j45QHKvwZBsks=; b=MDAfaLclYdlImR83c24XkLiBqW QX4e8WXT9xuJ4uZaThYrDzHXqQtV3lLE1VS2A59O1xwoRDzVniBzbqZmiltIoS+2 UsU5j7oWc/UunTCwt1Sa6S2rrYelIaWNw+adHKLgZ+YBXl5YJjHfpmxcULM57EI5 wey99AkmazrAjfSuiktoadK+HtNjboRqpNgBrL3FZsR6svIMo433l/DzjUrCNLsj tFaBcAjp/i5lDHmPssP6yanOvKCvD7H4N7ppiQPtkEcxF4Xd6l8vn2Kh9wuP5jv1 isOwrv3gKTOGa39TaILRn67XanTDAuk5lXnSEdqUeyhuutFepk9JoInBdHBA== 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=1723618323; x=1723704723; bh=vAJymv3/2VGXDhjMfmXOqsXr79Vg 5+j45QHKvwZBsks=; b=VuObgU35vzXTbXPZmEEBLvY19NHDjtNOSRDxM0NLPXyT KUaHb4bjfmIUU7gW50i2Jj8yb8gpXWDNiOL8j9hHTlbeBQmg4jmpPLzKdMi7GTGq JyIuingrgnNu+kLyOlgjbKFPQqL9Ef5Xaw3lYvv/GaBSz47MWtqmMA4ydeuZxj0V d3LaOfgq3GMh47mqu6IO/6Y6/ya6ybSRike2s/GCRHi5n+zLzY7FJXLegoB0HZ2P DfBEeY2dRnkgFBG5ktGlF6OH+saKeSj3SMr/ndHocvuxN8J2r3yIL44er7zvWN6F 0xTuy3ZRa9lIom4AEUmso1PBDhRHmqHEwgCvA1g3Fg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtfedgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddv necuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrih hmqeenucggtffrrghtthgvrhhnpeevkeekfffhiedtleduiefgjedttedvledvudehgfeu gedugffhueekhfejvdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeeipdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehmvgesthhtrgihlhhorhhrrdgtohhmpdhrtghpth htohepkhgrrhhthhhikhdrudekkeesghhmrghilhdrtghomhdprhgtphhtthhopehjrghm vghssehjrghmvghslhhiuhdrihhopdhrtghpthhtohepphhhihhllhhiphdrfihoohguud dvfeesghhmrghilhdrtghomhdprhgtphhtthhopehgihhtshhtvghrsehpohgsohigrdgt ohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Aug 2024 02:52:02 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 3d2122a5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 14 Aug 2024 06:51:43 +0000 (UTC) Date: Wed, 14 Aug 2024 08:52:00 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: James Liu , karthik nayak , Phillip Wood , Junio C Hamano , Taylor Blau Subject: [PATCH v4 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 () {