From patchwork Thu Aug 8 13:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13757437 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 2ACA618CBF3 for ; Thu, 8 Aug 2024 13:05:25 +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=1723122326; cv=none; b=CCCgPFQKakkcxDeFb84cJHPWYiGvt7C+xbETeqm+wXQtC6+65/vBVwPP5XO9feZI47Y/zkeJG6EikCFWZHhXtlaz3aMnYLeMD42jdIk15z+DQSu1/YFxoKISOe/yC4AJFn7ZJr+XaLaE98zuarc1/TD18SwFOEWh2C1rdi242ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122326; c=relaxed/simple; bh=xcIZBYzHtkb5xO9oiQTWKci5z+vcwhMIzGuQxjjcjCE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jYQU944U9HMzrDHYVfkSDtj8Mrs//MHxrLMcv/9+4TA1Ym6KRMZi7JInnOt/2qiyUYkeDiiH1Tj1LJZkDDpGvoLWF5wRxaVBoTXEov/9gHw3TDx+Jz4vJkyi6juEMdPqq89oYYX09f1eYO7zB/sMMJjQ03eU0rm+zJD+vMzc/7U= 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=Q2+xOGIn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=CuO5RP9q; 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="Q2+xOGIn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="CuO5RP9q" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 71D7F1151ABE; Thu, 8 Aug 2024 09:05:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 08 Aug 2024 09:05:24 -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=1723122324; x=1723208724; bh=xV2qufCYHt qM0Ny/e0o9FDvYdFCfpMhCbMGttLDJk48=; b=Q2+xOGInX/RmoXwjXQ6MFG55ro fRAkYL2K7aHOAlWr2haM6GoR2cAe7GO5QGLh6kteewXfBoWrsivVr7XPE60niiiw x2f1R9AWwQPQfjGHgiGyOow5DcZIMU6vgz7voCR7ridltkyBqnTkSaJVegYFojEn N8H54claWx37QBRhX6gzFvuqmXuOLmPj/xw5nAqFvTQg3acr4egU+86KQCgyL2VK KOq1BvvwKpKkBEExZbYHpM2SJ/9Gd1fjXEXb9/tjrY1JZYqlP2HoZWFAVukMsJ6+ vMRP7Ck7AXeifb2LEe5ek57sKrdUPZMF+2y9UdGi75Kw7UMB7bscHGJaTt+Q== 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=1723122324; x=1723208724; bh=xV2qufCYHtqM0Ny/e0o9FDvYdFCf pMhCbMGttLDJk48=; b=CuO5RP9qQBQnbfxTTR3MTJRgJedqi8y5TavJ/WwjwtsL GndH8JDaG/WM+InJi57dYSrC0HxsltsZAifpAB7d3M/x1/R34WA/4MWwNLV/f8u5 Y2qTeslYdGTpqqwOBz7Gd0EkZibtqxYeN9B8IPQ007OSfoSU9cflZxm/gLv6XPiG Zh3P/RmCZc95GmlA82ivbLFvOO+lq0SyY0FbczBCvkpLq6zG6RA1oypxL4eWouxa cBuQRNO8K1rNBZIlkK3X7wC8OkVckgF2XsNNHomspuGFshQFOf575K54uq+WnUhw 5vu/RrfnSfWSnXiC7tGvg2zI+f+OOmEwIv82N3nTxw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrledvgdeitdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecu hfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqe enucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeeh gfeltddtheejleffteenucevlhhushhtvghrufhiiigvpeeinecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtg hpthhtohepphhhihhllhhiphdrfihoohguuddvfeesghhmrghilhdrtghomhdprhgtphht thhopehjrghmvghssehjrghmvghslhhiuhdrihho X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Aug 2024 09:05:23 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 4c5e9b5c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 8 Aug 2024 13:05:16 +0000 (UTC) Date: Thu, 8 Aug 2024 15:05:21 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: James Liu , Phillip Wood Subject: [PATCH v2 11/22] builtin/fast-import: plug trivial memory leaks 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: Plug some trivial memory leaks in git-fast-import(1). Signed-off-by: Patrick Steinhardt --- builtin/fast-import.c | 8 ++++++-- t/t9300-fast-import.sh | 1 + t/t9304-fast-import-marks.sh | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin/fast-import.c b/builtin/fast-import.c index d21c4053a7..6dfeb01665 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -206,8 +206,8 @@ static unsigned int object_entry_alloc = 5000; static struct object_entry_pool *blocks; static struct hashmap object_table; static struct mark_set *marks; -static const char *export_marks_file; -static const char *import_marks_file; +static char *export_marks_file; +static char *import_marks_file; static int import_marks_file_from_stream; static int import_marks_file_ignore_missing; static int import_marks_file_done; @@ -3274,6 +3274,7 @@ static void option_import_marks(const char *marks, read_marks(); } + free(import_marks_file); import_marks_file = make_fast_import_path(marks); import_marks_file_from_stream = from_stream; import_marks_file_ignore_missing = ignore_missing; @@ -3316,6 +3317,7 @@ static void option_active_branches(const char *branches) static void option_export_marks(const char *marks) { + free(export_marks_file); export_marks_file = make_fast_import_path(marks); } @@ -3357,6 +3359,8 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list) free(f); string_list_insert(list, s)->util = ms; + + free(s); } static int parse_one_option(const char *option) diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 1e68426852..3b3c371740 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -7,6 +7,7 @@ test_description='test git fast-import utility' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash diff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh index 410a871c52..1f776a80f3 100755 --- a/t/t9304-fast-import-marks.sh +++ b/t/t9304-fast-import-marks.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test exotic situations with marks' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup dump of basic history' '