From patchwork Thu Aug 8 13:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13757430 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 3129818A6B3 for ; Thu, 8 Aug 2024 13:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122294; cv=none; b=ESssQZ4KZ8A+PgRoWC8PQlnRvOBEZw0vTgi+hc2baqf40hPRcxBxz7EpGYHEoDYJhkX11Y9hVAOgDhC8whXoLEn4/p2ZG4x7hzWFYEH9YXqiW5cv5CGUc/iylgj5TcTvdMqvtWSHi5BCEGhz57aeYscjyd7J/MXF46HpR90HUuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122294; c=relaxed/simple; bh=8I5e9Cxunt4osoT31+NxYD9EerZfoq/8ig6SWR4QFLA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uZjEmBGzrIQRo0rQT2cE9fCNuYvdoOE6H/WZQm+RYU8pY87E/dsJj8fU2CTEqwzcxAYOlS3aAcXN6JqImRNiMfw4Xl/XxOkQNQpMpit2YhOH8foSso4TotraeKReSLIZytLCpiifT6r1adq6BY4dIArQ/ftsb9DxGzoOFECeXc4= 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=SLMl1hgJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cS8x4jZC; arc=none smtp.client-ip=103.168.172.155 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="SLMl1hgJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cS8x4jZC" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 58EDE1151A9F; Thu, 8 Aug 2024 09:04:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 08 Aug 2024 09:04:52 -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=1723122292; x=1723208692; bh=ah8PAqvoEe 7xJ4BzJ9iftcfmGMWF5Y90yWAq+6wx1PA=; b=SLMl1hgJiKTW+pkY2ojW8Wp+M8 kl1kXsVjicxmNFYadM4FoG/7xC+h8QGRkv8MpTqmMQZRlFDAegUT2Tm66h/04PSi G10d3vUR7S3hc8TfxHx4XiXxryTKwE7cdvZhJfRZStLPqmhMU2LiaaKQIK64OoHd mLFtrAGT7wdESQRmN/xmM89VbBHbgXSThDswPRYgX881d80DmLKDreMGJrop6hkv tC8wRm0RD7IrB++EiykwQcexXVv0/+/5U/TukDDqKY22BC6A4WpQBijDQm3lxN+1 YSg+yGWaWfHlbkGi2kCihDkZFoQ6GXl4AYE4T0k+myIsyYtyZxzjthO1z1yQ== 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=1723122292; x=1723208692; bh=ah8PAqvoEe7xJ4BzJ9iftcfmGMWF 5Y90yWAq+6wx1PA=; b=cS8x4jZCQlfoptOelJ7VwS7zA13Z5B1RqjhG3OpWftEw XRpi6v8U5RFq9kM2+9/AAwmBCtM8mA2Wx7dZtI6+WoFPkA8xm0cgM3nI8lglTZw2 4xKSDYIgTYsTvOqTflhGAGyjXA0U8B0Vc6QwlsADWaiVQK72cx8orqJjyekh+/7j WuMrI64qXdlPI5oQt0C31bJcX0iekJLrIPla3AiTysPfvBTrZ10JBRwz7xq4pobY 5+cQbc1QYGf7lhfgvWsRgMFt2Ut0qOliCn1FNkSK+HPqmk9holKfVeJM1wMVBDFu s8VcWzhq4+1JxKDiEHmIHYO4vWmt4cf5v2QnX/ebZw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrledvgdeitdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecu hfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqe enucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeeh gfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehphhhilhhlihhprdifohhougduvdefsehgmhgrihhlrd gtohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehjrghmvghssehjrghmvghslhhiuhdrihho X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Aug 2024 09:04:51 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 9ecf1900 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 8 Aug 2024 13:04:44 +0000 (UTC) Date: Thu, 8 Aug 2024 15:04:48 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: James Liu , Phillip Wood Subject: [PATCH v2 04/22] object-name: fix leaking symlink paths in object context Message-ID: <9d3dc145e8a60ae446b890ae5b97f81bfd762f79.1723121979.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: 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 () {