From patchwork Fri Dec 30 02:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A23A2C4332F for ; Fri, 30 Dec 2022 02:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234344AbiL3CS5 (ORCPT ); Thu, 29 Dec 2022 21:18:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiL3CSp (ORCPT ); Thu, 29 Dec 2022 21:18:45 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A0717054 for ; Thu, 29 Dec 2022 18:18:42 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id d14so28851002edj.11 for ; Thu, 29 Dec 2022 18:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aU02WCHln0L0ZJco5xodojmRSFePyo0oq4S2iGzOG/g=; b=pXcYJbsveEGG4NepEPrry1IiBC60Syy2qGcxcVnJHcyAaoKiDxrGR6e+78cs+4cSqK gUfMyUN70mRRXpelM/BaATn4hSNrcuazS0ttlebvcQal8o5/rzSwul+W/qZMWKKxuBE7 8KYKBG5Izvn+IgmIIGWyXTtNSHjtaBWHu03niIjLyI/VvHatGt9+E6kkpy2LexTAAMYp pucuYY+w39d0epAMIQAG6BQPgd4W2bUg1IfJXjpNymAOMawKmfAq3f4fWQxANZKc6DXt jdLSKyhZTss2McUCi0D2UE0N9YPm1lMIS9BWZbBfG3zd4T+KXI4N6ObodC35hsaf0yQa Jlhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aU02WCHln0L0ZJco5xodojmRSFePyo0oq4S2iGzOG/g=; b=wcPDd+i3/CYG+gI57sOt+a3CUqIwtSpETudO4xk+de2vW0gk1QXYei05JkvXPLkcoE HznYHUgmJ6NO/Ty3Shad25UUjWlfFgtG4Vc8xZLIYzhUZfgE7EGPiPYmAxjEFpig4HEp Wc0Vnx8NhnrluEpsineJDgtonGr/l8Nnn7iLpM8ENvstPh++7EQkFtXmPHmMOA++sj+m Yzq4uqg6l4T/aslXLfg4+q9WchbOhpzMMyUnVdQIGZF9ezhDUTWxscaqPAL6fVLKOPbJ oCB+hngGRNxdlfG2islRvKErvo6qY+PArqY6O6/MAqBZyEHdu+AA0S0q24MPz3s7YCWB fStg== X-Gm-Message-State: AFqh2koxfulquyDcldIcCXKZ4eLa9tYjpA1oN7pEnZOXfVI3qMXLvM9X jJB33OGePipV9faRHXdViRZ5xdAqBvi9nQ== X-Google-Smtp-Source: AMrXdXsvvdDmrYC9ErSjG/NYaGpiZksZjskJaV67vw7fi5UX3WJHOpsu/bOOMOGRvtoV/Wzx9Lvf0g== X-Received: by 2002:a05:6402:220e:b0:483:a6d8:7ad with SMTP id cq14-20020a056402220e00b00483a6d807admr15118237edb.24.1672366720481; Thu, 29 Dec 2022 18:18:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:40 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 01/20] tests: mark tests as passing with SANITIZE=leak Date: Fri, 30 Dec 2022 03:18:16 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the "ab/various-leak-fixes" topic was merged in [1] only t6021 would fail if the tests were run in the "GIT_TEST_PASSING_SANITIZE_LEAK=check" mode, i.e. to check whether we marked all leak-free tests with "TEST_PASSES_SANITIZE_LEAK=true". Since then we've had various tests starting to pass under SANITIZE=leak. Let's mark those as passing, this is when they started to pass, narrowed down with "git bisect": - t5317-pack-objects-filter-objects.sh: In faebba436e6 (list-objects-filter: plug pattern_list leak, 2022-12-01). - t3210-pack-refs.sh, t5613-info-alternate.sh, t7403-submodule-sync.sh: In 189e97bc4ba (diff: remove parseopts member from struct diff_options, 2022-12-01). - t1408-packed-refs.sh: In ab91f6b7c42 (Merge branch 'rs/diff-parseopts', 2022-12-19). - t0023-crlf-am.sh, t4152-am-subjects.sh, t4254-am-corrupt.sh, t4256-am-format-flowed.sh, t4257-am-interactive.sh, t5403-post-checkout-hook.sh: In a658e881c13 (am: don't pass strvec to apply_parse_options(), 2022-12-13) - t1301-shared-repo.sh, t1302-repo-version.sh: In b07a819c05f (reflog: clear leftovers in reflog_expiry_cleanup(), 2022-12-13). - t1304-default-acl.sh, t1410-reflog.sh, t5330-no-lazy-fetch-with-commit-graph.sh, t5502-quickfetch.sh, t5604-clone-reference.sh, t6014-rev-list-all.sh, t7701-repack-unpack-unreachable.sh: In b0c61be3209 (Merge branch 'rs/reflog-expiry-cleanup', 2022-12-26) 1. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0023-crlf-am.sh | 1 + t/t1301-shared-repo.sh | 1 + t/t1302-repo-version.sh | 1 + t/t1304-default-acl.sh | 1 + t/t1408-packed-refs.sh | 1 + t/t1410-reflog.sh | 1 + t/t3210-pack-refs.sh | 1 + t/t4152-am-subjects.sh | 2 ++ t/t4254-am-corrupt.sh | 2 ++ t/t4256-am-format-flowed.sh | 1 + t/t4257-am-interactive.sh | 2 ++ t/t5317-pack-objects-filter-objects.sh | 1 + t/t5330-no-lazy-fetch-with-commit-graph.sh | 1 + t/t5403-post-checkout-hook.sh | 1 + t/t5502-quickfetch.sh | 1 + t/t5604-clone-reference.sh | 1 + t/t5613-info-alternate.sh | 2 ++ t/t6014-rev-list-all.sh | 1 + t/t6021-rev-list-exclude-hidden.sh | 1 + t/t7403-submodule-sync.sh | 1 + t/t7701-repack-unpack-unreachable.sh | 1 + 21 files changed, 25 insertions(+) diff --git a/t/t0023-crlf-am.sh b/t/t0023-crlf-am.sh index f9bbb91f64e..575805513a3 100755 --- a/t/t0023-crlf-am.sh +++ b/t/t0023-crlf-am.sh @@ -2,6 +2,7 @@ test_description='Test am with auto.crlf' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh cat >patchfile <<\EOF diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 93a2f91f8a5..a1251f65100 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -8,6 +8,7 @@ test_description='Test shared repository initialization' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Remove a default ACL from the test dir if possible. diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index 0acabb6d11b..83c327ac2c8 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -5,6 +5,7 @@ test_description='Test repository version check' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh index c69ae41306c..31b89dd9693 100755 --- a/t/t1304-default-acl.sh +++ b/t/t1304-default-acl.sh @@ -9,6 +9,7 @@ test_description='Test repository with default ACL' # => this must come before . ./test-lib.sh umask 077 +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # We need an arbitrary other user give permission to using ACLs. root diff --git a/t/t1408-packed-refs.sh b/t/t1408-packed-refs.sh index 41ba1f1d7fc..9469c79a585 100755 --- a/t/t1408-packed-refs.sh +++ b/t/t1408-packed-refs.sh @@ -5,6 +5,7 @@ test_description='packed-refs entries are covered by loose refs' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index aa59954f6c5..6c45965b1e4 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -7,6 +7,7 @@ test_description='Test prune and reflog expiration' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_have () { diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 577f32dc71f..07a0ff93def 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -12,6 +12,7 @@ semantic is still the same. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'enable reflogs' ' diff --git a/t/t4152-am-subjects.sh b/t/t4152-am-subjects.sh index 4c68245acad..9f2edba1f83 100755 --- a/t/t4152-am-subjects.sh +++ b/t/t4152-am-subjects.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test subject preservation with format-patch | am' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh make_patches() { diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh index 54be7da1611..45f1d4f95e5 100755 --- a/t/t4254-am-corrupt.sh +++ b/t/t4254-am-corrupt.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git am with corrupt input' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh make_mbox_with_nul () { diff --git a/t/t4256-am-format-flowed.sh b/t/t4256-am-format-flowed.sh index 2369c4e17ad..1015273bc82 100755 --- a/t/t4256-am-format-flowed.sh +++ b/t/t4256-am-format-flowed.sh @@ -2,6 +2,7 @@ test_description='test format=flowed support of git am' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t4257-am-interactive.sh b/t/t4257-am-interactive.sh index aed8f4de3d6..f26d7fd2dbd 100755 --- a/t/t4257-am-interactive.sh +++ b/t/t4257-am-interactive.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='am --interactive tests' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'set up patches to apply' ' diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index 5b707d911b5..b26d476c646 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -5,6 +5,7 @@ test_description='git pack-objects using object filtering' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Test blob:none filter. diff --git a/t/t5330-no-lazy-fetch-with-commit-graph.sh b/t/t5330-no-lazy-fetch-with-commit-graph.sh index 2cc7fd7a476..5eb28f0512d 100755 --- a/t/t5330-no-lazy-fetch-with-commit-graph.sh +++ b/t/t5330-no-lazy-fetch-with-commit-graph.sh @@ -2,6 +2,7 @@ test_description='test for no lazy fetch with the commit-graph' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup: prepare a repository with a commit' ' diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index 978f240cdac..cfaae547398 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -7,6 +7,7 @@ test_description='Test the post-checkout hook.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh index b160f8b7fb7..7b3ff21b984 100755 --- a/t/t5502-quickfetch.sh +++ b/t/t5502-quickfetch.sh @@ -5,6 +5,7 @@ test_description='test quickfetch from local' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index 2734e37e880..dc86dea1333 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -7,6 +7,7 @@ test_description='test clone --reference' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh base_dir=$(pwd) diff --git a/t/t5613-info-alternate.sh b/t/t5613-info-alternate.sh index 895f46bb911..7708cbafa98 100755 --- a/t/t5613-info-alternate.sh +++ b/t/t5613-info-alternate.sh @@ -4,6 +4,8 @@ # test_description='test transitive info/alternate entries' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'preparing first repository' ' diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh index c9bedd29cba..16b8bd1d090 100755 --- a/t/t6014-rev-list-all.sh +++ b/t/t6014-rev-list-all.sh @@ -2,6 +2,7 @@ test_description='--all includes detached HEADs' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh diff --git a/t/t6021-rev-list-exclude-hidden.sh b/t/t6021-rev-list-exclude-hidden.sh index 32b2b094138..11c50b7c0dd 100755 --- a/t/t6021-rev-list-exclude-hidden.sh +++ b/t/t6021-rev-list-exclude-hidden.sh @@ -2,6 +2,7 @@ test_description='git rev-list --exclude-hidden test' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh index ea92ef52a5e..ff09443a0a4 100755 --- a/t/t7403-submodule-sync.sh +++ b/t/t7403-submodule-sync.sh @@ -11,6 +11,7 @@ These tests exercise the "git submodule sync" subcommand. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index b7ac4f598a8..ebb267855fe 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -5,6 +5,7 @@ test_description='git repack works correctly' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh fsha1= From patchwork Fri Dec 30 02:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA6AC3DA79 for ; Fri, 30 Dec 2022 02:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbiL3CTF (ORCPT ); Thu, 29 Dec 2022 21:19:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiL3CSp (ORCPT ); Thu, 29 Dec 2022 21:18:45 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39A2517055 for ; Thu, 29 Dec 2022 18:18:43 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id c17so28839840edj.13 for ; Thu, 29 Dec 2022 18:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uOj+o2phs01pUDldCm15uyOAtoTjLseArBFdBqfacRg=; b=Zs3S3ZTdBhjBCskUPjbAX6XXelRT30Ka/7NrKMx5eWsEodFQIMjhJsPZjeVfPoEE0o AbmtU9qXMgoXUkrCOj8MHK/Zl5K1Xuo3w1J/73UhOMRzObAu49HF0tHJrF0FYhw+pgfQ SiXau+Zml1/pMiIijoSq7rzG+NSJcQbYGNbyUDAwNpQEh2s6Em2mbjbxcXl1l0PIB8bn UD1ggwkKeie6ipj3wQZtIu9xdvFVsjCQWB4I/wRqRezxhcc+Aiqy2WYX0C30vUn9ocfT MzhNKFWwK/OJulaBqH9RaIC44PIj079Hak6a0W7hxLQRw5C5cO3YnVHcwYF0HvdES9d0 3i7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uOj+o2phs01pUDldCm15uyOAtoTjLseArBFdBqfacRg=; b=AzGI7Rz3ztkYbxV54j4mRZZfO0f24tP6M4Gmri78k/HnIiOy7AZHsPtoMZEJIL1LlA HAxnYWZWEjdqRA5i7Imwy7fFkrBZSsBjuVZGkp3Gymz03LHLsPBhNhXBmBmv0BPqAeIb L12kR+kSHIY992bFyZDzBRM5zlb50haKkTEoKPcnYmk2s/0Smeh6kaV0vpq/a+fKVZKJ +FTJIwV/0lOQB82hTaNEgHWPbrCae8dRpSxTi0zAAlFSPCaTxi+cnOUctwiI9iby+w2A Mtw0iizpOOmUyLHG2Uajmjl6SwXrGheUcTxmrtZHZPVooBV8bQ7VOz03OVpv6eh/jkSj hKWg== X-Gm-Message-State: AFqh2koGMccLe76oOPRhAYf0ZYaOTybAabPKKWZsMid0MhVtZzE5sOrT b1HTEn+MXlje9ih7MthZQh+J6Ce0aEO7aw== X-Google-Smtp-Source: AMrXdXspHdvvDSbKRtl8cEigxBXBfsv4EhbVOcENZ1S5iwmwmdZzZEPgAQ1CiGehd7KrjUd9M048fg== X-Received: by 2002:a05:6402:14d6:b0:479:6bf2:a9bb with SMTP id f22-20020a05640214d600b004796bf2a9bbmr23889521edx.15.1672366721447; Thu, 29 Dec 2022 18:18:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:40 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 02/20] bundle.c: don't leak the "args" in the "struct child_process" Date: Fri, 30 Dec 2022 03:18:17 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a leak that's been here since 7366096de9d (bundle API: change "flags" to be "extra_index_pack_args", 2021-09-05), if can't verify the bundle we didn't call child_process_clear() to clear the "args". But rather than doing that let's verify the bundle before we start preparing the process we're going to spawn, if we get an error we don't need to push anything to the "args". Signed-off-by: Ævar Arnfjörð Bjarmason --- bundle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundle.c b/bundle.c index 4ef7256aa11..9ebb10a8f72 100644 --- a/bundle.c +++ b/bundle.c @@ -627,6 +627,10 @@ int unbundle(struct repository *r, struct bundle_header *header, enum verify_bundle_flags flags) { struct child_process ip = CHILD_PROCESS_INIT; + + if (verify_bundle(r, header, flags)) + return -1; + strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL); /* If there is a filter, then we need to create the promisor pack. */ @@ -638,8 +642,6 @@ int unbundle(struct repository *r, struct bundle_header *header, strvec_clear(extra_index_pack_args); } - if (verify_bundle(r, header, flags)) - return -1; ip.in = bundle_fd; ip.no_stdout = 1; ip.git_cmd = 1; From patchwork Fri Dec 30 02:18:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46B7BC3DA7A for ; Fri, 30 Dec 2022 02:19:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbiL3CS7 (ORCPT ); Thu, 29 Dec 2022 21:18:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiL3CSp (ORCPT ); Thu, 29 Dec 2022 21:18:45 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A8B1705F for ; Thu, 29 Dec 2022 18:18:44 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id ud5so48720336ejc.4 for ; Thu, 29 Dec 2022 18:18:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ue8HkUEhcsSu+wXsYg/oJCiIcWNWJ0EmEuOtVxLQfAU=; b=NLHRWsahwSB5kDohfa80Vz2hfb5nyOoavv72vcU+858SiSqMQ7q6qL+v20YH3VE+cj 5iF6nP/esZAwjEGurJKAXIf0D0gO2skFh/LIrNHSq9Nhd+I5XfbwQs7pzmGVOMOdYK5Y o1AK1WxzsZI0EGzrjn3C3qM0P/HZYS9axcXF4885crw7CfH/POp4IQPZ4OC2Ery6OOzd LOqoiw2hw570cinbV3jhysEp7P+K53iyo2Gn6nhYKuf8c52YT6T58PcIwWFeof41jPPS PP1WXtQx6Ha9Ucxtzsakq52QASGugYyCxD+ycsXVHoJ7wP1Ak/oeZicFv/Qp+oWPdEwu pt2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ue8HkUEhcsSu+wXsYg/oJCiIcWNWJ0EmEuOtVxLQfAU=; b=6gPIy3wn9T+y2oVmOVZQaCGY3ktTF2vGAL4op/jmkBW8tPBb7mVF3guqJ8bLRY15un cRw0HYo8CgACuuEOUKsfaDr3jwM+KClqEwAGo0AOqxXcujMhl3hcpcpMzphLkIHaPyBG HAJtSrvVAVjFBCy09CGQ5G8V3fAIR0j3MZwtR4Oh0sUQWczEE2Mnh+QQGpvLrVuiIk+k zIBIhqIJ3qUjgW8bdiTNi03UIkSe7AeSf6MYPMt7Nn4cmdSIP/Dah+DWlgFMfgSrA7Sr IJXSncDtpRSJ3K6+3VKil4O1F0f61Dm/PokyYbXue1XXWfeYXdQP4HXmyzTboXtBh1Uq f4yA== X-Gm-Message-State: AFqh2kqCv1xI8eB3IbfjMZiWQ99RK+0IyCLMVvAndTmuIhe4SLBlyKs7 OfGsdk3aBbFxdHjS1t3gDr7Tvrt2Z34AIg== X-Google-Smtp-Source: AMrXdXvc7TWeZWBrJQjMf+bHlsy1WM3g23Ce7vMfRBzZkAwQcmd6CJ8wurCrKYWVhAK+xu+XfFl6bw== X-Received: by 2002:a17:907:a0d0:b0:7c1:55aa:2e84 with SMTP id hw16-20020a170907a0d000b007c155aa2e84mr23880124ejc.1.1672366722356; Thu, 29 Dec 2022 18:18:42 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:41 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 03/20] commit-graph: use free() instead of UNLEAK() Date: Fri, 30 Dec 2022 03:18:18 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 0bfb48e6723 (builtin/commit-graph.c: UNLEAK variables, 2018-10-03) this was made to UNLEAK(), but we can just as easily invoke the free_commit_graph() function added in c3756d5b7fc (commit-graph: add free_commit_graph, 2018-07-11) instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit-graph.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index e8f77f535f3..0102ac8540e 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -67,6 +67,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix) int fd; struct stat st; int flags = 0; + int ret; static struct option builtin_commit_graph_verify_options[] = { OPT_BOOL(0, "shallow", &opts.shallow, @@ -111,8 +112,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix) if (!graph) return !!open_ok; - UNLEAK(graph); - return verify_commit_graph(the_repository, graph, flags); + ret = verify_commit_graph(the_repository, graph, flags); + free_commit_graph(graph); + return ret; } extern int read_replace_refs; From patchwork Fri Dec 30 02:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A543C3DA79 for ; Fri, 30 Dec 2022 02:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234368AbiL3CTN (ORCPT ); Thu, 29 Dec 2022 21:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbiL3CSq (ORCPT ); Thu, 29 Dec 2022 21:18:46 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185621707D for ; Thu, 29 Dec 2022 18:18:45 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id z11so13024544ede.1 for ; Thu, 29 Dec 2022 18:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=14JMX+D5fOZCP/BStNku8nHaXsfXlD3Lgx067PwizW4=; b=AGmsud1Y2wUxKF6e9Vgfhf/g4da+U7tQNlhursq4qm1Wz21EegmxpYS/7VLwieMKQg iKHkszx5lRfPXcSEeUo8Nb34pfwS5REQ4iwd14WTTI5xm8jX80Gw1qlu+fCXDdc6Lai7 XRQ4EeA0cGuAeIp1Z1+zsZrv+unjof8wXv3o1/UTpdeN1qwJShMt/mZ6CQLjNZ1s7AtJ dRR64ynXay2PKZAVD/b8SkljXIMtmPc1BC8Qo2Sx/2L//I9DsDd5Ugpyr+Mtk+v0KI1K MEpsXSiW/FI7sebMVMYeQAx1Cj9oQWUL7jGse2A/yDyXBxujwEpAGnN68MQxluztRg7s Vbyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=14JMX+D5fOZCP/BStNku8nHaXsfXlD3Lgx067PwizW4=; b=L0JrR4JB/8SAeFXmr1Tg6BvBYAn8LOnJQ9NSfgr/y6FXpK2/pNku8GkrF+Mcj4bMQg YmEzEaA/F1k7W9ZSdzKwf+7FLmp2xEhXKCFt592VtCpxtdVL6AiBI2afh+/XstOJG/4P dPdFPJ5cUgcJ1hHbUMFRf7iAcI7yiKd8zqI59MDIOrHDSTVFRswma0hFQ10cylo9SpLN cXr4kQMkZHmYFjWSjAOz/xjpL8ScrKjBU9rHN+2mH2yLH/OU4LN+hzin+XRM9NTg0SH6 qtL2ra5TvQseKkVViuAkEKzsAywuiDv3bVDblJ03oPeVIVprpGLunPeyoeRlxnSN9eht TXEQ== X-Gm-Message-State: AFqh2koJQw9ch1zuybQwD/RjBcKL+RIkGH9NOhOQzSHZZdpwf1LkTN59 ucx6LzamZhHKHrc64SG+m+8tTzHQ4O4JTw== X-Google-Smtp-Source: AMrXdXsRTGSmxyeitqkuMKFQQmvLN55Bscq7ITLuvE4Xb259t6ha+BiE6zT22SfRp6S8nKa9MrzU+w== X-Received: by 2002:aa7:c1c9:0:b0:468:fd17:aeb9 with SMTP id d9-20020aa7c1c9000000b00468fd17aeb9mr27015822edp.0.1672366723246; Thu, 29 Dec 2022 18:18:43 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:42 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 04/20] clone: use free() instead of UNLEAK() Date: Fri, 30 Dec 2022 03:18:19 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change an UNLEAK() added in 0c4542738e6 (clone: free or UNLEAK further pointers when finished, 2021-03-14) to use a "to_free" pattern instead. In this case the "repo" can be either this absolute_pathdup() value, or in the "else if" branch seen in the context the the "argv[0]" argument to "main()". We can only free() the value in the former case, hence the "to_free" pattern. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/clone.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index f518bb2dc1f..48156a4f2c2 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -892,6 +892,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) int is_bundle = 0, is_local; int reject_shallow = 0; const char *repo_name, *repo, *work_tree, *git_dir; + char *repo_to_free = NULL; char *path = NULL, *dir, *display_repo = NULL; int dest_exists, real_dest_exists = 0; const struct ref *refs, *remote_head; @@ -949,7 +950,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) path = get_repo_path(repo_name, &is_bundle); if (path) { FREE_AND_NULL(path); - repo = absolute_pathdup(repo_name); + repo = repo_to_free = absolute_pathdup(repo_name); } else if (strchr(repo_name, ':')) { repo = repo_name; display_repo = transport_anonymize_url(repo); @@ -1392,7 +1393,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) free(unborn_head); free(dir); free(path); - UNLEAK(repo); + free(repo_to_free); junk_mode = JUNK_LEAVE_ALL; transport_ls_refs_options_release(&transport_ls_refs_options); From patchwork Fri Dec 30 02:18:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BD8EC3DA7A for ; Fri, 30 Dec 2022 02:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234365AbiL3CTK (ORCPT ); Thu, 29 Dec 2022 21:19:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234101AbiL3CSr (ORCPT ); Thu, 29 Dec 2022 21:18:47 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185FE17054 for ; Thu, 29 Dec 2022 18:18:46 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id x22so48666872ejs.11 for ; Thu, 29 Dec 2022 18:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d/DfACsDIlyuucgMms9rcMEzW74R3zbwttZLDNULjTs=; b=mwWprGgmOvNb/+AefLLoqYjyZKQD/ogCyuXNr6PSOm/Xfn2PKWzilhRbDFG5blRJe3 Zm+fE4x0X5TrkSUUpZBxBhKAP3vcy26UTaTCpgewqZfY9kHrgS69iR7axFRSyx+rarl9 U/lVxSdPemZhdDZGXQpohDQ0rJM3MNB0lTa/cp9whGyPNXaEXXezT00zWGwvk79qbf6z N/qvjlq48xRUkJS1MYjyLc/55ij8NaMaPpJAuHfHYg0AKXDSEuwr751LKlc/2JFVMp4t YkhU9o6wBGGQ3YGxwBWfyj2dOrHWqM38q5LoNYtiOEGiCcxrE3WaCwOfwLJMDhm3hpR6 whcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d/DfACsDIlyuucgMms9rcMEzW74R3zbwttZLDNULjTs=; b=LXacRvMmP/E9Ukr7vL134Gp1tupk10aM5kQQqzSALuFT5vYz7gTWZkOKKK4so38lWZ ZYoa1pecMs7OziwfSY+srEKGTTci06tUsIlmmn9u6Gx/1WaCul7ps/OUsQ6X/e9VHhBA nly/fFUMBRjLAxvLgHx91r2xllJl7GGyPaP150LSF+Up0hU5No6JuJBlsEF26Ixc2BzQ A6jgZPeJNLF3Eev+NThTKYtJsaezrRy1fzjdjypZwLgrBheYrMnUHSZ/M2VzjU/yZrT+ KIJxgvuNOH/uqGmaqj4/k+ejhLs8gi39pB8OMp69z7b3dJ8uMsC5Ei/KX/83ybldEac9 Z6ig== X-Gm-Message-State: AFqh2kqVJjBughtQHSZoF2YRUUIUHHHf3DMujLx4bzpHuNniLQK162M+ 64FwD5cGu/VnENUw7rBJz0dTnvKwWxhx8g== X-Google-Smtp-Source: AMrXdXus0/CBD/2zhE4yadZWMrUHB6ohwdwbrYgqexaG1kMCf6FTLSqDPR9X+R/krWPibLRMvjMBYQ== X-Received: by 2002:a17:907:6292:b0:846:56fe:6c68 with SMTP id nd18-20020a170907629200b0084656fe6c68mr25787546ejc.21.1672366724196; Thu, 29 Dec 2022 18:18:44 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:43 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 05/20] various: add missing clear_pathspec(), fix leaks Date: Fri, 30 Dec 2022 03:18:20 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix memory leaks resulting from a missing clear_pathspec(). - archive.c: Plug a leak in the "struct archiver_args", and clear_pathspec() the "pathspec" member that the "parse_pathspec_arg()" call in this function populates. - builtin/clean.c: Fix a memory leak that's been with us since 893d839970c (clean: convert to use parse_pathspec, 2013-07-14). - builtin/reset.c: Add clear_pathspec() calls to cmd_reset(), including to the codepaths where we'd return early. - builtin/stash.c: Call clear_pathspec() on the pathspec initialized in push_stash(). Signed-off-by: Ævar Arnfjörð Bjarmason --- archive.c | 1 + builtin/clean.c | 1 + builtin/reset.c | 11 ++++++++--- builtin/stash.c | 7 +++++-- t/t5001-archive-attr.sh | 1 + t/t5004-archive-corner-cases.sh | 2 ++ t/t7105-reset-patch.sh | 2 ++ t/t7106-reset-unborn-branch.sh | 2 ++ t/t7107-reset-pathspec-file.sh | 1 + t/t7301-clean-interactive.sh | 1 + 10 files changed, 24 insertions(+), 5 deletions(-) diff --git a/archive.c b/archive.c index 941495f5d78..a2d813e50db 100644 --- a/archive.c +++ b/archive.c @@ -710,6 +710,7 @@ int write_archive(int argc, const char **argv, const char *prefix, string_list_clear_func(&args.extra_files, extra_file_info_clear); free(args.refname); + clear_pathspec(&args.pathspec); return rc; } diff --git a/builtin/clean.c b/builtin/clean.c index b2701a28158..b15eab328b7 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -1092,5 +1092,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix) strbuf_release(&buf); string_list_clear(&del_list, 0); string_list_clear(&exclude_list, 0); + clear_pathspec(&pathspec); return (errors != 0); } diff --git a/builtin/reset.c b/builtin/reset.c index fea20a9ba0b..e9c10618cd3 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -390,7 +390,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (reset_type != NONE) die(_("options '%s' and '%s' cannot be used together"), "--patch", "--{hard,mixed,soft}"); trace2_cmd_mode("patch-interactive"); - return run_add_interactive(rev, "--patch=reset", &pathspec); + update_ref_status = run_add_interactive(rev, "--patch=reset", &pathspec); + goto cleanup; } /* git reset tree [--] paths... can be used to @@ -439,8 +440,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix) LOCK_DIE_ON_ERROR); if (reset_type == MIXED) { int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; - if (read_from_tree(&pathspec, &oid, intent_to_add)) - return 1; + if (read_from_tree(&pathspec, &oid, intent_to_add)) { + update_ref_status = 1; + goto cleanup; + } the_index.updated_skipworktree = 1; if (!no_refresh && get_git_work_tree()) { uint64_t t_begin, t_delta_in_ms; @@ -488,5 +491,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) discard_index(&the_index); +cleanup: + clear_pathspec(&pathspec); return update_ref_status; } diff --git a/builtin/stash.c b/builtin/stash.c index bb0fd861434..45bffdf54bb 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1727,6 +1727,7 @@ static int push_stash(int argc, const char **argv, const char *prefix, OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END() }; + int ret; if (argc) { force_assume = !strcmp(argv[0], "-p"); @@ -1766,8 +1767,10 @@ static int push_stash(int argc, const char **argv, const char *prefix, die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file"); } - return do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, - include_untracked, only_staged); + ret = do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, + include_untracked, only_staged); + clear_pathspec(&ps); + return ret; } static int push_stash_unassumed(int argc, const char **argv, const char *prefix) diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh index 2f6eef5e372..04d300eeda7 100755 --- a/t/t5001-archive-attr.sh +++ b/t/t5001-archive-attr.sh @@ -3,6 +3,7 @@ test_description='git archive attribute tests' TEST_CREATE_REPO_NO_TEMPLATE=1 +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh SUBSTFORMAT='%H (%h)%n' diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index ae508e21623..9f2c6da80e8 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test corner cases of git-archive' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # the 10knuls.tar file is used to test for an empty git generated tar diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh index fc2a6cf5c7a..9b46da7aaa7 100755 --- a/t/t7105-reset-patch.sh +++ b/t/t7105-reset-patch.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git reset --patch' + +TEST_PASSES_SANITIZE_LEAK=true . ./lib-patch-mode.sh test_expect_success PERL 'setup' ' diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index ecb85c3b823..a0b67a0b843 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git reset should work on unborn branch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh index 523efbecde1..af5ea406db3 100755 --- a/t/t7107-reset-pathspec-file.sh +++ b/t/t7107-reset-pathspec-file.sh @@ -2,6 +2,7 @@ test_description='reset --pathspec-from-file' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_tick diff --git a/t/t7301-clean-interactive.sh b/t/t7301-clean-interactive.sh index a07e8b86de2..d82a3210a1d 100755 --- a/t/t7301-clean-interactive.sh +++ b/t/t7301-clean-interactive.sh @@ -2,6 +2,7 @@ test_description='git clean -i basic tests' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh From patchwork Fri Dec 30 02:18:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EACB6C4332F for ; Fri, 30 Dec 2022 02:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234361AbiL3CTH (ORCPT ); Thu, 29 Dec 2022 21:19:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234007AbiL3CSq (ORCPT ); Thu, 29 Dec 2022 21:18:46 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6E91704D for ; Thu, 29 Dec 2022 18:18:45 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id s5so28867846edc.12 for ; Thu, 29 Dec 2022 18:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yoBbEH2ijIuLF2v+LEPT44edGXSS+hZN9201U3uowYk=; b=Mk3VWJ4Aq5jZ45xkxCQxnXhZ2ye7i+pvnoWxIvWwxWcb4bxgWKcrQbqzgtkhfe9z+r lJqW1v1gzLlsAuLTGDILb0CaZ+6boG6+M+u0fokX82NKtYDLEGDGXayZtS9AbE0Dfbv1 sBgya2wWHypu8wygtQXC9Yl8ODPKQ3dGxfeF609rP0Sh4V9IBT7OfwpXUMasdaDGW5yZ PXhb1Zl5cYMPjWyFITuRtN5u1qQyYaAH4Mquubd+/H/FWZpVp4BPECtXry/V67WsXzl5 IL9SC2lyb5FHepkOj9MEUYc8KfuTJu446NGNc0VbNxaJIMhj4iFIQZejS24QHCu0s8ms dEgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yoBbEH2ijIuLF2v+LEPT44edGXSS+hZN9201U3uowYk=; b=WW9nUlKMXKsvwFr9LEsqNz8eVpwXqKdAfzJC28a2H0QtOtlXgGpDm5JJc9d3b1oGhF sT23qrToSFSJ2uaDqG98VB01+7+tk5hnf4ic4G6esHCbItWMCaW0HVX/hUzjBZnG6sbe rpCZvUkYOE78Nm/BAJURGgUIDRU+5WwkhZmkH46IpRpk3l33Wvj4XXFz/go1GyF1cnIY zkqUWlctuUnqNzX6oHJZnmfRQ6qgtaCb773/2fTfVe+lUALhbCa9r/epPCkKEFLBAjc4 4pFwkqPWnjPdySunaVPg4f8CEWXIPZ/3gxC8h7z7M/ytO+eBNuko9z9JGcljevnPHSRO yBJA== X-Gm-Message-State: AFqh2kp4f8Gzzkr8iYMKGfYWo0czYYEO/S1vOGJkkP4hhhhBoA0fRYw9 LG46FzYFOgeepgGmqxw0BLxgcsYiItkotg== X-Google-Smtp-Source: AMrXdXul18e/cxjrLwpq5nbTv18h2up5F/OT1zTTqq40pnu+77CENKzpyurA8mjMKISR7nEyLwdsAw== X-Received: by 2002:a05:6402:528f:b0:47e:eaae:9a69 with SMTP id en15-20020a056402528f00b0047eeaae9a69mr24878779edb.41.1672366725092; Thu, 29 Dec 2022 18:18:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:44 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 06/20] name-rev: don't xstrdup() an already dup'd string Date: Fri, 30 Dec 2022 03:18:21 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When "add_to_tip_table()" is called with a non-zero "shorten_unambiguous" we always return an xstrdup()'d string, which we'd then xstrdup() again, leaking memory. See [1] and [2] for how this leak came about. We could xstrdup() only if "shorten_unambiguous" wasn't true, but let's instead inline this code, so that information on whether we need to xstrdup() is contained within add_to_tip_table(). 1. 98c5c4ad015 (name-rev: allow to specify a subpath for --refs option, 2013-06-18) 2. b23e0b9353e (name-rev: allow converting the exact object name at the tip of a ref, 2013-07-07) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/name-rev.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 15535e914a6..49fae523694 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -273,17 +273,6 @@ static int subpath_matches(const char *path, const char *filter) return -1; } -static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous) -{ - if (shorten_unambiguous) - refname = shorten_unambiguous_ref(refname, 0); - else if (skip_prefix(refname, "refs/heads/", &refname)) - ; /* refname already advanced */ - else - skip_prefix(refname, "refs/", &refname); - return refname; -} - struct name_ref_data { int tags_only; int name_only; @@ -309,11 +298,19 @@ static void add_to_tip_table(const struct object_id *oid, const char *refname, int shorten_unambiguous, struct commit *commit, timestamp_t taggerdate, int from_tag, int deref) { - refname = name_ref_abbrev(refname, shorten_unambiguous); + char *short_refname = NULL; + + if (shorten_unambiguous) + short_refname = shorten_unambiguous_ref(refname, 0); + else if (skip_prefix(refname, "refs/heads/", &refname)) + ; /* refname already advanced */ + else + skip_prefix(refname, "refs/", &refname); ALLOC_GROW(tip_table.table, tip_table.nr + 1, tip_table.alloc); oidcpy(&tip_table.table[tip_table.nr].oid, oid); - tip_table.table[tip_table.nr].refname = xstrdup(refname); + tip_table.table[tip_table.nr].refname = short_refname ? + short_refname : xstrdup(refname); tip_table.table[tip_table.nr].commit = commit; tip_table.table[tip_table.nr].taggerdate = taggerdate; tip_table.table[tip_table.nr].from_tag = from_tag; From patchwork Fri Dec 30 02:18:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B56CC3DA7A for ; Fri, 30 Dec 2022 02:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbiL3CTT (ORCPT ); Thu, 29 Dec 2022 21:19:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbiL3CSs (ORCPT ); Thu, 29 Dec 2022 21:18:48 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E63217055 for ; Thu, 29 Dec 2022 18:18:47 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id r26so23668506edc.5 for ; Thu, 29 Dec 2022 18:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gc6HsEQht7ylJKQPR1/iLQMr5yITGoX6jGratZyCUeA=; b=BvWE1ttu1JzzAaQ1frJ7Q58UemyQlMFIsLrVb1cuzfaArZv9k8HifUBfMI2HzR9hyU XJgujz0zchyZFsYm99XKDe0ta4kqHAeQwntKxDv0yKa5xCykBwCSIS9jpBkdyiFP1gGl eqx3wXFzxE/ALrbs4+lj2NCpJ++EPkekYn72WzVIWQtpvvF/u1sxMoFy3U9KYz3d9VX+ zdeno0chnrB4qAiUGBoz7wFpfk1U3gD30YMxOhI1OCVHamjFjanSuC8D4B/RAW+V0xYK l64zDnB9Dl+0DE5k9kUkyYK5scGprxuy+It+c+4x4RVKHJufm0/2SnkCJLbsN9S6cogR pKsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gc6HsEQht7ylJKQPR1/iLQMr5yITGoX6jGratZyCUeA=; b=Wjz6BbTeZwZGKzsx3jT9Xqjmv/7Lw/skQLCCOaGJY31vokVb2WgKZgTOWqwfGoO9nH 3Trijicra5alO8zt1dKNICAVEmcNSGkdHYKgHak6+gRS6VL0rmMFwotlDExnBwy6ItsB PUgNosx6xHThZ3a/DoRXghfkcduFLiBT7sc1FDAxwWHbTl1BJ9SM3RMBB2aFv6ZzMBFz 1pwbZud+7VXAKZZycaebBczJPDdoEsI/0o5zUMsD2x/2Ys0TBRrN0D2IfL2gPXbgfy68 pzD82mPvEfVjjNKRvhWFduBUwXIuk2PfPSuxW5ndoHxULxXabXMGAhI1u9y7JY9Njo58 Vxzw== X-Gm-Message-State: AFqh2kpEBoe6Eh5apWgbfSpm+IYQglZEt6vAJIg5po+TSXEMCaqrt8Kh VG4qvu7n8dumNJDHosqlHFwEzR2YtiD6bw== X-Google-Smtp-Source: AMrXdXvG8ZQCbnz8bEUgMaAmULSQpOhYuTVsc1irKXoyrL9v8LGR/FEu2g26V50vm0b1s3qRPXea2Q== X-Received: by 2002:a05:6402:a55:b0:475:9918:37ce with SMTP id bt21-20020a0564020a5500b00475991837cemr26282055edb.13.1672366725904; Thu, 29 Dec 2022 18:18:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:45 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 07/20] repack: fix leaks on error with "goto cleanup" Date: Fri, 30 Dec 2022 03:18:22 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change cmd_repack() to "goto cleanup" rather than "return ret" on error, when we returned we'd potentially skip cleaning up the string_lists and other data we'd allocated in this function. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/repack.c | 13 +++++++------ t/t6011-rev-list-with-bad-commit.sh | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/repack.c b/builtin/repack.c index c1402ad038f..f6493795318 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -948,7 +948,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) ret = start_command(&cmd); if (ret) - return ret; + goto cleanup; if (geometry) { FILE *in = xfdopen(cmd.in, "w"); @@ -977,7 +977,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) fclose(out); ret = finish_command(&cmd); if (ret) - return ret; + goto cleanup; if (!names.nr && !po_args.quiet) printf_ln(_("Nothing new to pack.")); @@ -1007,7 +1007,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) &existing_nonkept_packs, &existing_kept_packs); if (ret) - return ret; + goto cleanup; if (delete_redundant && expire_to) { /* @@ -1039,7 +1039,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) &existing_nonkept_packs, &existing_kept_packs); if (ret) - return ret; + goto cleanup; } } @@ -1115,7 +1115,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) string_list_clear(&include, 0); if (ret) - return ret; + goto cleanup; } reprepare_packed_git(the_repository); @@ -1172,10 +1172,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix) write_midx_file(get_object_directory(), NULL, NULL, flags); } +cleanup: string_list_clear(&names, 1); string_list_clear(&existing_nonkept_packs, 0); string_list_clear(&existing_kept_packs, 0); clear_pack_geometry(geometry); - return 0; + return ret; } diff --git a/t/t6011-rev-list-with-bad-commit.sh b/t/t6011-rev-list-with-bad-commit.sh index bad02cf5b83..b2e422cf0f7 100755 --- a/t/t6011-rev-list-with-bad-commit.sh +++ b/t/t6011-rev-list-with-bad-commit.sh @@ -2,6 +2,7 @@ test_description='git rev-list should notice bad commits' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Note: From patchwork Fri Dec 30 02:18:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D95D9C4332F for ; Fri, 30 Dec 2022 02:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234370AbiL3CTR (ORCPT ); Thu, 29 Dec 2022 21:19:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234261AbiL3CSv (ORCPT ); Thu, 29 Dec 2022 21:18:51 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 878A21705F for ; Thu, 29 Dec 2022 18:18:48 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id m21so28876558edc.3 for ; Thu, 29 Dec 2022 18:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XwY/rw3XQB9PSPpd72bwLHGQPxrK+BM6Q0jY0901V44=; b=I4CmsCauH9GOoYss/omM6m6alt+ofJfc6+mRd9dlBFd7Alb5zUTDebDgD1HD4p2S7m 4rwlgO12dfh2eNFPWCyB6DMeSeRA4HqVPa/oyKbwmYQVGiwy4zcgrkhasEpsl4tXOnM1 rgNau+tUk48M6bIKqYJLkdIs+DpOHcTKiZGRcvntORZm7DCDidy/yMp5MKkjuImMw35b GL8GnrIDgaGH2ob8OP+0HJJwgFCvh+RdVsDhlLUNs+4aO545re4DpfkIimeITcFzcJLt hCX2cevoenHjqBbwJKRLNSFkm7G0i1L9L3E2GVivyfqk8NLxM/Accg15yUQ23kQlvaLm 9Omg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XwY/rw3XQB9PSPpd72bwLHGQPxrK+BM6Q0jY0901V44=; b=Y6bJi8y5tP2z6Ye/KMk4sFh5gpCZWARHh/aeRfvYE/GgRy2QYapwhmtMUAu4cnDQPP xkiZLp1h3vPR5MNFMGvrz/nV7sX/AnL3X3EL/KnP01o/boZH59hH8rfEGBhV9CY3q5DD tfkaPBAbi41eZYyvkM7aubdmK6cMwFs7WoEFYyzwUmXH4RW0Ij2dErhThagKTFD18NOh t5p+A86vQczL5tBRmIUFkP4M6Fq2uTYSuJaRWeHlhjeUJj7lNDjBj8APF3a7KYUsdgiV gbf9sIRYUqz0U8E2OygqVMCwjEKa83G3ZkVwwune1h45kJbM/3p9vExFjgtDjiEFRm40 a0XQ== X-Gm-Message-State: AFqh2kq4IO/87xMlfwRdsxHhUit9Nf8qAFpabgSsM2vjrhaAAX1weYyR RrxYfvK9ciUpf8YqN35zbpp5SjRwBidgjA== X-Google-Smtp-Source: AMrXdXsXd9+Tq9pTZ2M5YXhcdVizjmBrrzP1bsbcVvseaOjTPfXrEXkhyoE5TinBFEhBUS8RvQtiZw== X-Received: by 2002:a05:6402:914:b0:479:dc9c:1144 with SMTP id g20-20020a056402091400b00479dc9c1144mr27720628edz.24.1672366726717; Thu, 29 Dec 2022 18:18:46 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:46 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 08/20] worktree: fix a trivial leak in prune_worktrees() Date: Fri, 30 Dec 2022 03:18:23 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We were leaking both the "struct strbuf" in prune_worktrees(), as well as the "path" we got from should_prune_worktree(). Since these were the only two uses of the "struct string_list" let's change it to a "DUP" and push these to it with "string_list_append_nodup()". For the string_list_append_nodup() we could also string_list_append() the main_path.buf, and then strbuf_release(&main_path) right away. But doing it this way avoids an allocation, as we already have the "struct strbuf" prepared for appending to "kept". Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/worktree.c | 6 +++--- t/t2401-worktree-prune.sh | 1 + t/t2406-worktree-repair.sh | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 591d659faea..865ce9be22b 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -173,7 +173,7 @@ static void prune_worktrees(void) { struct strbuf reason = STRBUF_INIT; struct strbuf main_path = STRBUF_INIT; - struct string_list kept = STRING_LIST_INIT_NODUP; + struct string_list kept = STRING_LIST_INIT_DUP; DIR *dir = opendir(git_path("worktrees")); struct dirent *d; if (!dir) @@ -184,14 +184,14 @@ static void prune_worktrees(void) if (should_prune_worktree(d->d_name, &reason, &path, expire)) prune_worktree(d->d_name, reason.buf); else if (path) - string_list_append(&kept, path)->util = xstrdup(d->d_name); + string_list_append_nodup(&kept, path)->util = xstrdup(d->d_name); } closedir(dir); strbuf_add_absolute_path(&main_path, get_git_common_dir()); /* massage main worktree absolute path to match 'gitdir' content */ strbuf_strip_suffix(&main_path, "/."); - string_list_append(&kept, strbuf_detach(&main_path, NULL)); + string_list_append_nodup(&kept, strbuf_detach(&main_path, NULL)); prune_dups(&kept); string_list_clear(&kept, 1); diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh index 3d28c7f06b2..568a47ec426 100755 --- a/t/t2401-worktree-prune.sh +++ b/t/t2401-worktree-prune.sh @@ -5,6 +5,7 @@ test_description='prune $GIT_DIR/worktrees' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success initialize ' diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh index 5c44453e1c1..8970780efcc 100755 --- a/t/t2406-worktree-repair.sh +++ b/t/t2406-worktree-repair.sh @@ -2,6 +2,7 @@ test_description='test git worktree repair' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' From patchwork Fri Dec 30 02:18:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41627C4332F for ; Fri, 30 Dec 2022 02:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234369AbiL3CTP (ORCPT ); Thu, 29 Dec 2022 21:19:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234307AbiL3CSv (ORCPT ); Thu, 29 Dec 2022 21:18:51 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594561707D for ; Thu, 29 Dec 2022 18:18:49 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id i9so28881115edj.4 for ; Thu, 29 Dec 2022 18:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/UhFr1CSb/9yv6NlmxFi4aysJq20IKGEdJxGQGezW9A=; b=IajM3YkWt/ZmMf9GrEyK8nafa0oVqHh504XoYjDjlQFibl/J4RMGZfzR3wK/qC2WfT PyppwXZO+OXy/W1U5jQxum+KrbfkZqmHOtS49U4oaa9YrxTBIViClmeEwWErk1r3tAhM 9+1lPLFGsCUFXBhe5yAbOIvQHBLKT7SbJrK5lgk06UGhyRzmQ4dJIg39FhAkdSqCn8Ax DAVU3Gn0PRWozmsuivx8tCMJQQVStbDV60bxO00V4GCeH5YDJpURNsri5/Q8KB5vzaNR 82uSCUTL6hohigL5UTewAshqCwoNFNMIaEofnjwmIyNkOnnWaemX4CYxoEUWUzROlCj8 2ePg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/UhFr1CSb/9yv6NlmxFi4aysJq20IKGEdJxGQGezW9A=; b=ew5Jp+NrYEI3ofm0nwx/2igp/tbHLLdsAEUoLn/rsrhlzh76ueeVS2QgkWpebMDM0D C7v63gl92fRHyzjYFA8L5iihUaK2kfbmoD7+yhXVcSVaI9a8TPQqarvr+X3/i99rYrfQ VXGuApBUSJ32wteGPY3sTwm82kCn38vhCARG0teXa4R+sr76FsockSShk1H8kqeg3F2r S+fgmzgnnIL+5x+FPebUxUQbKxwdn4ud74hedwojIfOZlvjVxneB7LwASw4NTNjgn530 WMCp6OqLY+KAZ911G1Box/RwKqLEXOJH18Rxg8bBQUvsz47xfZgYoQpvr5APDiww2Nxj M4sg== X-Gm-Message-State: AFqh2krImvMQE/K6Jtxx+s0sZzQ7UVHN6vGQiKVayqgZ/NDVqwoH9OY8 T3hTz5SijqU3TOBBVBu2NtAvA+Y6CnuKBA== X-Google-Smtp-Source: AMrXdXvgr8I82plT60g+IZ9b+zEKSFW0AEBEpuRRZ4CpMUlScyvCxyH7pwEVj0gVTo3XQEG6EyRavA== X-Received: by 2002:a05:6402:2a08:b0:470:4d71:6d43 with SMTP id ey8-20020a0564022a0800b004704d716d43mr28308621edb.25.1672366727572; Thu, 29 Dec 2022 18:18:47 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:46 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 09/20] http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main() Date: Fri, 30 Dec 2022 03:18:24 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Free the "dir" variable after we're done with it. Before 917adc03608 (http-backend: add GIT_PROJECT_ROOT environment var, 2009-10-30) there was no leak here, as we'd get it via getenv(), but since 917adc03608 we've xstrdup()'d it (or the equivalent), so we need to free() it. We also need to free the "cmd_arg" variable, which has been leaked ever since it was added in 2f4038ab337 (Git-aware CGI to provide dumb HTTP transport, 2009-10-30). Signed-off-by: Ævar Arnfjörð Bjarmason --- http-backend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http-backend.c b/http-backend.c index 6eb3b2fe51c..67819d931ce 100644 --- a/http-backend.c +++ b/http-backend.c @@ -786,6 +786,7 @@ int cmd_main(int argc, const char **argv) if (!getenv("GIT_HTTP_EXPORT_ALL") && access("git-daemon-export-ok", F_OK) ) not_found(&hdr, "Repository not exported: '%s'", dir); + free(dir); http_config(); max_request_buffer = git_env_ulong("GIT_HTTP_MAX_REQUEST_BUFFER", @@ -795,5 +796,6 @@ int cmd_main(int argc, const char **argv) setenv(GIT_PROTOCOL_ENVIRONMENT, proto_header, 0); cmd->imp(&hdr, cmd_arg); + free(cmd_arg); return 0; } From patchwork Fri Dec 30 02:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B49F8C4332F for ; Fri, 30 Dec 2022 02:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234373AbiL3CTV (ORCPT ); Thu, 29 Dec 2022 21:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234312AbiL3CSv (ORCPT ); Thu, 29 Dec 2022 21:18:51 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F06617422 for ; Thu, 29 Dec 2022 18:18:50 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id m18so48641504eji.5 for ; Thu, 29 Dec 2022 18:18:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tr1Rsly295TTDRzmr/4QKVtou++xrIda0Uwrmqg/FnI=; b=qY6V58ZRZ15jOqMVwfOU5M2TKzm/oynKl2lRUwBE84AeLY2lxaLOPk6bd6aMJXj6aK CBbdkJiCK9BCQ8HX0L0ZjE2XLoHmQ/9icezqIgKHr8RbqJiQCubOq6irM3Ei7KlHr0OP xFNICAn35FeUkhNqn49MdxS1uBS7HHjqq5YXVsP6wqWx/T4W4qQezktRMKFMzcPCiJjk 5lINMNhWTR9OsxHUCW1kqVaTITn9//2sKQPJQftnG+ZDrkw5HgZr5mVSDGfKFA5wnpR9 IxEFg1EfmhHmtB5X03nj6pzH3CggtsMWwNJJ0lBdpejD89aoz4OG71AqLYXMtXBAl9vV EnAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tr1Rsly295TTDRzmr/4QKVtou++xrIda0Uwrmqg/FnI=; b=x0n/fCKU8DY4HhEGKXH4PU68N3EKLu0qXe4UNiNjs99O7bP3aVAebeHwWhrMTJo7lZ DfvrmH71JTF9CYnyTkwNXaBH75HIDwMyOXy0yYLnMCWITo8nRW3EZVdF9XyQawxhqluN 8StKGQ6zp2a+b85CAlMvvYMowVJbsGcIZ+TZ3NiXnBCV0pSYkSvc3iujF2BGsAbVMOFn VGG2CVi2qD0ywFrsccVsfvHOu0N07Y26D13i4lpOWLG8oLanmQq5cIiMvuv3Hvxue3jh it6hddGgjPGaGEz6Pn6c71L11W8xAWvjY9bMjlT9n25zZVHznd4UbQ+CGQnhqYxUNzdW 6Zjw== X-Gm-Message-State: AFqh2kqKdTv1EFt/6vIyRLSVB6wLhabBbJxi+sc9pWsSkLlLvxSb9X7Y 6I6ntVEG4u/ummZO0aC4GCs704MKQc7G4g== X-Google-Smtp-Source: AMrXdXv1odsR3jWtxGCOB9mZLFGGTisbhTFxQuzOTpftlCP+szT7FLd0sJ9BEMZxG3vP7SnDvzULSw== X-Received: by 2002:a17:907:d109:b0:818:3f54:8df7 with SMTP id uy9-20020a170907d10900b008183f548df7mr34278708ejc.2.1672366728411; Thu, 29 Dec 2022 18:18:48 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:47 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 10/20] http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}() Date: Fri, 30 Dec 2022 03:18:25 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us ever since 2f4038ab337 (Git-aware CGI to provide dumb HTTP transport, 2009-10-30). In this case we're not calling regerror() after a failed regexec(), and don't otherwise use "re" afterwards. We can therefore simplify this code by calling regfree() right after the regexec(). An alternative fix would be to add a regfree() to both the "return" and "break" path in this for-loop. Signed-off-by: Ævar Arnfjörð Bjarmason --- http-backend.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/http-backend.c b/http-backend.c index 67819d931ce..8ab58e55f85 100644 --- a/http-backend.c +++ b/http-backend.c @@ -759,10 +759,14 @@ int cmd_main(int argc, const char **argv) struct service_cmd *c = &services[i]; regex_t re; regmatch_t out[1]; + int ret; if (regcomp(&re, c->pattern, REG_EXTENDED)) die("Bogus regex in service table: %s", c->pattern); - if (!regexec(&re, dir, 1, out, 0)) { + ret = regexec(&re, dir, 1, out, 0); + regfree(&re); + + if (!ret) { size_t n; if (strcmp(method, c->method)) @@ -774,7 +778,6 @@ int cmd_main(int argc, const char **argv) dir[out[0].rm_so] = 0; break; } - regfree(&re); } if (!cmd) From patchwork Fri Dec 30 02:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD352C4332F for ; Fri, 30 Dec 2022 02:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234383AbiL3CTc (ORCPT ); Thu, 29 Dec 2022 21:19:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiL3CS4 (ORCPT ); Thu, 29 Dec 2022 21:18:56 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA9C17882 for ; Thu, 29 Dec 2022 18:18:50 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id c17so28840089edj.13 for ; Thu, 29 Dec 2022 18:18:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0pq4xbFTh2jF0itR3ZIPXejvF+NP8xceGshYiJYNvNA=; b=iGxJiXifWfg0p1otGqPS2zLPmTXcfwaPKD6f8NfMSeQngRA/gpyKACup1r1qr8yx6o 4rD6fW05Pv/JGm8AVrjuplWBF5cTRrIfdCbPJxsir/cgeU50BAsY8cQtWhOB9G6Q2iaB XT+tibYjhWmsaR2n+dmULcDL3RbLBxfHNboNkVKIrbawypgPhVZ5I0JAoPQwcDzIm0ug D014goBd5pUQDP0W4E6a0y4HlEPIJxn8VcHKJetp/5sFkAd41UB++77JaqS0Yxebdq6K 6rYIMFJnZXC4OROyaDZm0sP03cufPbZRO6aWiKDWYyAUnCQnEo3P/e0R47R9DD0Gzurd TXEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0pq4xbFTh2jF0itR3ZIPXejvF+NP8xceGshYiJYNvNA=; b=y4Nrj6ZFuU3yYupbUVFXGNDSvQQdelcPKIGtNuV0MekDFIygvrRSIJg+1hvxlyxaXv tgLdIo/KUorpX1fghufEOep1N0j4p4Y2V55qUVu+ZM1tMgG3dqST5nY1CGzgUmCGl6PR XYVoQ8izNma0cFIQ3Q8Ai9wMVA0wDgXUW6FnhFwTzqzSaTG/QLJy2Hj/nBos69i/X5w+ KBsWQikqh2X79YYe8O9LJ/fWO2xAzJjCdVavfoSV+yjc2TEHTJaZ4zOUdBVUlsDwQjeq 9GH9NmrZOXr2rylMfJ29g0Kk6WSZ2jjbzmXoNNseBc2FrGC7bWn8ie61Oa1Wu8NhPj0W NDVw== X-Gm-Message-State: AFqh2kp6w6i05XAV2Nv8GCjaFuIBGHs6BBUDnLJsVIbfTY6IPOQoLXWg +QGD6Q5ymtyq+H7AttPHFOjWJF91j0khig== X-Google-Smtp-Source: AMrXdXsIRiINjAZaUBQw5pGigBvVsfBb5nbpcqZChXVXD8GvKTK15taLeadqcoBcl3JlN4Vt+F0KEQ== X-Received: by 2002:a05:6402:1770:b0:461:8be6:1ac5 with SMTP id da16-20020a056402177000b004618be61ac5mr23613215edb.3.1672366729340; Thu, 29 Dec 2022 18:18:49 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:48 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 11/20] commit-graph: fix a parse_options_concat() leak Date: Fri, 30 Dec 2022 03:18:26 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the parse_options_concat() was added to this file in 84e4484f128 (commit-graph: use parse_options_concat(), 2021-08-23) we wouldn't free() it if we returned early in these cases. Since "result" is 0 by default we can "goto cleanup" in both cases, and only need to set "result" if write_commit_graph_reachable() fails. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit-graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 0102ac8540e..93704f95a9d 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -269,8 +269,8 @@ static int graph_write(int argc, const char **argv, const char *prefix) if (opts.reachable) { if (write_commit_graph_reachable(odb, flags, &write_opts)) - return 1; - return 0; + result = 1; + goto cleanup; } if (opts.stdin_packs) { From patchwork Fri Dec 30 02:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D3EBC4332F for ; Fri, 30 Dec 2022 02:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234376AbiL3CTX (ORCPT ); Thu, 29 Dec 2022 21:19:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234319AbiL3CS4 (ORCPT ); Thu, 29 Dec 2022 21:18:56 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DBCC1704D for ; Thu, 29 Dec 2022 18:18:52 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id c17so28840114edj.13 for ; Thu, 29 Dec 2022 18:18:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1SvFYXt9ZKBMVGx//NwLoFy5ZCj83eS9eIuWeWGABmc=; b=YBpGv7x1iH4urbmUxwM2oUW0PkxrHYpUyWXNbf49cuIvB/tfAWB4ZEPQLf5fYvy1ZM hdEeBlpZyVzCEQLL5uSKHZbFzPod6PoHG2MEr5TOLUCrzHBwOKP/BQtCDG5V2anDpRn+ L2MEM1bRNF/YEoLBT/J3ECdyBmzQMNpfI4RL8E5sycjkypT8TrS1OctaeiZr94YNtQvc yVsRYRjQ9wvlQE4YZ2uNWiLgnWmnrma/QSD2frt+99RZY3b66CpnCa2y95RfJqeb6F4/ AemDd8g04io+CU/5WcyX6hKTYmqs+ZG4JgSayN1yS7LvWsZOqSMIfWX/DVD+aQz3BMaa MfTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1SvFYXt9ZKBMVGx//NwLoFy5ZCj83eS9eIuWeWGABmc=; b=alQYqhG7QrdyOdiRnnDvLTGb8Aiwi7GDwiEHpEtwLnENR+9/cPQjvWUER/prYpqoo1 PCFLMi5gqulu/pfsYZcIXLni8uS1MvOBXJTbib4ZQqSWR0jIWypySHfrSr6DNTR0/Emh LpVNb/sCrBlvbWcmQj/gRbucfpmgfBzeYJVEUBRCT6vZPrmwfk1T3l/Zx77oPFiQkCIu Fx77cNhqHdN5qagWf+icgDZFO5baEKSCWlt3Bnkp/B3J19ZXMgb7Kbs3OIP9W1RRwBNj GNqCKz1F6aWSsES8eEit8cWRNW3RwB8JImWTeI+y2WImepUYE+HxwI1iT0aYVuTlUWI8 GqjA== X-Gm-Message-State: AFqh2kpwPc4CfmnNUKV4jf69L8PSxutA+IWx4ImyEbg6u+e5p4YdCfo4 sOxgsdgG2GUSgL6NbONi8WZ2Qgd5225DgA== X-Google-Smtp-Source: AMrXdXsgcUNBHvD6lGouWOth2Wslr2DUOlYJyZTTAsMDapidFfkAsdowsvtEotAX6Tbz82wk6B7lfA== X-Received: by 2002:a05:6402:1149:b0:482:d62c:cde with SMTP id g9-20020a056402114900b00482d62c0cdemr18171316edw.13.1672366730533; Thu, 29 Dec 2022 18:18:50 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:49 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 12/20] show-branch: free() allocated "head" before return Date: Fri, 30 Dec 2022 03:18:27 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stop leaking the "head" variable, which we've been leaking since it was originally added in [1], and in its current form since [2] 1. ed378ec7e85 (Make ref resolution saner, 2006-09-11) 2. d9e557a320b (show-branch: store resolved head in heap buffer, 2017-02-14). Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/show-branch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index c013abaf942..358ac3e519a 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -956,5 +956,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (shown_merge_point && --extra < 0) break; } + free(head); return 0; } From patchwork Fri Dec 30 02:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99F9FC4332F for ; Fri, 30 Dec 2022 02:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234378AbiL3CT0 (ORCPT ); Thu, 29 Dec 2022 21:19:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234333AbiL3CS4 (ORCPT ); Thu, 29 Dec 2022 21:18:56 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B3E1175B9 for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id r26so23668682edc.5 for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lrs563dAEATCYIKh5dag6CODDZIJfrY3R84jSz3aTco=; b=bWBKoEQ/x+FZ+qwKuu72X9JXQd2RAwOXf8PDuXg26oX7uTgdMan7nL4fyBCwjjgvlA 6IA+xlX0RvAZ6rHcm8yzJRqPzv7JMqtkBkdqh1uhIP4AppTSaaid4YjetKhP8IqIKoy3 I1x7/k9g4urBzMP1XAbVezQ7eh+YDyWAarKSHKB0myPpcTMHUGsa3B69ibfQcAhBxxoh H6IUdaKp49FoUWCn/Mr+Fy5AxrdGu7e39r+bwKoYxEaLOb4FVrtM2mk8eEI5w25BUqvC NUSnMKxwsvMXwNSHkXxGTL+BA/cJweDU997IeMDZVHcLp3lqihMC0Fu87p7E9/SqZWtm fChw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lrs563dAEATCYIKh5dag6CODDZIJfrY3R84jSz3aTco=; b=F7e9dwCRS2X6Pg9Tk4k37JATrRbsh07BTeQoGf6IO9MSmFX+tYR7qt7TK+D1U2MbIP lFxs1rjaAK2zqXWsiSPbmNi/CMVm614JwrqBLAREuev6rNglLsPE4RTDvLvu3+qmrd9c TPIzq/4/jjmkTMeAOA9pnDJuGHhZUx28oxp+5b/8S3mNlgrWrdZGa2y8pqFyWUTwD+hi 5Uk9JRcdnJh4WVsMMSSGsJOGBv2ycRkfyEFzi3Zgyz4ZHKiJMuBsvexBVsRtxbf91s6I GkKcDbjrq1t/2Sz1yfbaDwFDHkh7omgTtFKlUKLa6UK4MKeSE6Yxo5P20EfayvZHim/N 92dQ== X-Gm-Message-State: AFqh2krupbXA8tHKTqWB2zaprd3gDz8+nlBTkts6vDDwacWi9cFCEDPu ZsXf8OzBSBnce4jOV3cgLVAa9ycKmq8VTA== X-Google-Smtp-Source: AMrXdXveYUrpx/+9uxHaCiVW0HlB8ZeUFV1ZF18gsXN/G8wNziwVuHzRp9DdE4lQs+h7xCMNFKiihg== X-Received: by 2002:a05:6402:299b:b0:480:cbe7:9ee2 with SMTP id eq27-20020a056402299b00b00480cbe79ee2mr22076841edb.22.1672366731369; Thu, 29 Dec 2022 18:18:51 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:50 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 13/20] builtin/merge.c: always free "struct strbuf msg" Date: Fri, 30 Dec 2022 03:18:28 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Follow-up 465028e0e25 (merge: add missing strbuf_release(), 2021-10-07) and address the "msg" memory leak in this block. We could free "&msg" before the "goto done" here, but even better is to avoid allocating it in the first place. By repeating the "Fast-forward" string here we can avoid using a "struct strbuf" altogether. Suggested-by: René Scharfe Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/merge.c | 11 ++++------- t/t6439-merge-co-error-msgs.sh | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 0f093f2a4f2..91dd5435c59 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1560,7 +1560,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix) !common->next && oideq(&common->item->object.oid, &head_commit->object.oid)) { /* Again the most common case of merging one remote. */ - struct strbuf msg = STRBUF_INIT; + const char *msg = have_message ? + "Fast-forward (no commit created; -m option ignored)" : + "Fast-forward"; struct commit *commit; if (verbosity >= 0) { @@ -1570,10 +1572,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix) find_unique_abbrev(&remoteheads->item->object.oid, DEFAULT_ABBREV)); } - strbuf_addstr(&msg, "Fast-forward"); - if (have_message) - strbuf_addstr(&msg, - " (no commit created; -m option ignored)"); commit = remoteheads->item; if (!commit) { ret = 1; @@ -1592,9 +1590,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) goto done; } - finish(head_commit, remoteheads, &commit->object.oid, msg.buf); + finish(head_commit, remoteheads, &commit->object.oid, msg); remove_merge_branch_state(the_repository); - strbuf_release(&msg); goto done; } else if (!remoteheads->next && common->next) ; diff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh index 52cf0c87690..0cbec57cdab 100755 --- a/t/t6439-merge-co-error-msgs.sh +++ b/t/t6439-merge-co-error-msgs.sh @@ -5,6 +5,7 @@ test_description='unpack-trees error messages' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh From patchwork Fri Dec 30 02:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90C14C4332F for ; Fri, 30 Dec 2022 02:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234385AbiL3CTf (ORCPT ); Thu, 29 Dec 2022 21:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234340AbiL3CS4 (ORCPT ); Thu, 29 Dec 2022 21:18:56 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E45F0178BE for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id l29so21832633edj.7 for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ihL02fWLnPVa1G+vouJKVEijt+XqGqjvL0PoGlNa2RY=; b=mtTQXLgfXSFRekrhLcDghcsT5u3KOqa0oW9KTjeVXj5+XgGBSvooHFwlJiOOU17qpd uNG7UdE2a8+Zl4P3/lPHAgBDAzk7EM0A/tJTSwRy0fy+Yj9jvft9x75AT4Aho3TVUbB3 OCKkYxbHcw0Ng1R22ZerIcLBpcWewZTtwxNk7dwUvuIu3V12qyKdWX+9scxcC8/qKn8O 1riXiyPfKFKapT0Fn0Ym0RadJ2HR7S2/Bbn+Uz8Ati6NH4jmImsvw4itPPu+tSpQoeI4 rKAc4A6Y0U/Sxaduda9Q7F8PsH4wmziUxM1EtSDyyiqNp1bAFPfcAo86PinsS+sRM270 sNkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ihL02fWLnPVa1G+vouJKVEijt+XqGqjvL0PoGlNa2RY=; b=ZQZhQ1vF2ymBJRHODCLQNbRvY+hU78huVB8QiVK2+0elksdGPi2FgY8l039Ulco8L/ uSHCKFJvQlkTU2Op1o+5UsMsKzZAi/tLd3auZ/kZkNVahVhQUxWbzqc2vytfbmtmozQG BjSxdX9MOCVMxZ9YkSU4g/EwJYfTzEprt7rNtpoErC9ZLA88ihdLkLP6bKuMEfHlJZsR YCw0fU1RemcIS+ROrK9MYRpE5oQSaC8O+2sXnUN5/7jZ2HmU18OYPG+Wl6z4YO3oxWw/ Jq4QsfMVLRjEwx4Vo8I5JZuzZKem8reAifcBz/7HK3iuTN90jHOdkYciJwXUOwke6AI0 iwAA== X-Gm-Message-State: AFqh2koXUpk2ywDYcWzdxSNyrZeqQmFsvyJK6/rYKEw7t50NCRNBU3V9 174vvOan1su1LFtOk9qZQBfcQFq3IGtnNg== X-Google-Smtp-Source: AMrXdXtnAs2ci5aT+bxEVXMoP0ihYPMw6WHegSGz1Bq0JbmtkjdGmOxngz+4sYs1rRCfAdHSQfEL0Q== X-Received: by 2002:a05:6402:174c:b0:467:8dd2:b42 with SMTP id v12-20020a056402174c00b004678dd20b42mr24089728edx.10.1672366732150; Thu, 29 Dec 2022 18:18:52 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:51 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 14/20] builtin/merge.c: free "&buf" on "Your local changes..." error Date: Fri, 30 Dec 2022 03:18:29 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Plug a memory leak introduced in [1], since that change didn't follow the "goto done" pattern introduced in [2] we'd leak the "&buf" memory. 1. e4cdfe84a0d (merge: abort if index does not match HEAD for trivial merges, 2022-07-23) 2. d5a35c114ab (Copy resolve_ref() return value for longer use, 2011-11-13) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/merge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/merge.c b/builtin/merge.c index 91dd5435c59..2b13124c497 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1618,7 +1618,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) error(_("Your local changes to the following files would be overwritten by merge:\n %s"), sb.buf); strbuf_release(&sb); - return 2; + ret = 2; + goto done; } /* See if it is really trivial. */ From patchwork Fri Dec 30 02:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EB1DC4332F for ; Fri, 30 Dec 2022 02:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234381AbiL3CT2 (ORCPT ); Thu, 29 Dec 2022 21:19:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234335AbiL3CS4 (ORCPT ); Thu, 29 Dec 2022 21:18:56 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7C5A178B5 for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id c17so28840176edj.13 for ; Thu, 29 Dec 2022 18:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=haUot/xIAfYVQDjzJA68WZl7D4dmBs9l/ik3MXovgVE=; b=ilooEiuOgAsGXkPm0uQkeu/oGYuNjwOwhrpDz7+ZyRXI4Y/mkTKdFb0bIvMC5W/Flb FmdTkV/FE2FpBA9L/RL+uOBMqCGzhKkZPIJsdtp+IsMOjmhvCY05FOZvBexUyvD+a5NP bRwL+oh6xDv/kF4nfCzw7iAiY3CVrqbdgjTzIYouTpZdvWwrxAjz2sKsDV8VzmdywFU2 j6CLHanWRFuEa+5vlh2GJNau5G1KSH/oRU4vxvpTKh5oDvXGJqCoDsKU40tXCw+rrlkx CAsNNKq4w6IIAu6i1Ts7sjN9hjKSK96IRyFcjGJzeg/OrSGDsHjzf7tzx+ptecOF2VKw dmfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=haUot/xIAfYVQDjzJA68WZl7D4dmBs9l/ik3MXovgVE=; b=FYYFOTaAGqzAJbye5xqBK5uiwGuS3VumPxiSn2m48hsJKfuieoqIe0l48sPRCCNdUc ERDAFP1H9x026vE1ntaGTD/CTgYAO1eAr74kz5m4qpJhZdKz9/Exh/MQOX9JfNj+eCn0 qwYY0MbX+uCLyZR3SNJTY0FS4nBj9+ULQYI1tZHWIi9q6wu//h4v4MBn7AJaOdjOYUR3 M3WC66FOTYBxuEWryuim1GgumXtQOqV/m4menqcfPFOSt9icBeqJMnUFTnGRyo4ngcGl 8p6jRnHtM8pjvvFy+mOvuBwNit7bmwmzW59MxMeyClZIVCWpEn5fBMq3by1pj1ls5KoB 956g== X-Gm-Message-State: AFqh2kqxwNxWhLD4FdqkU0ILGuJGHElqSagfw/IynyzCZIMsFZ5QaSpG 6Fk2hjq47zoT+y3sN2P52OAReXO6LUFJHg== X-Google-Smtp-Source: AMrXdXvsDFClY5UtN979NJHKCvIYMMX2zNckWtzUQupj6KD67oPw8z87vs7rGrwy9hXv83Y++tfyYw== X-Received: by 2002:a50:eb06:0:b0:46c:b221:8605 with SMTP id y6-20020a50eb06000000b0046cb2218605mr26581957edp.0.1672366733033; Thu, 29 Dec 2022 18:18:53 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:52 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 15/20] connected.c: free(new_pack) in check_connected() Date: Fri, 30 Dec 2022 03:18:30 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us since this code was introduced in c6807a40dcd (clone: open a shortcut for connectivity check, 2013-05-26). We'd never free() the "new_pack" that we'd potentially allocate. Since it's initialized to "NULL" it's safe to call free() here unconditionally. Signed-off-by: Ævar Arnfjörð Bjarmason --- connected.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/connected.c b/connected.c index b90fd61790c..e4d404e10b2 100644 --- a/connected.c +++ b/connected.c @@ -38,7 +38,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, if (!oid) { if (opt->err_fd) close(opt->err_fd); - return err; + goto cleanup; } if (transport && transport->smart_options && @@ -85,8 +85,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, promisor_pack_found: ; } while ((oid = fn(cb_data)) != NULL); - free(new_pack); - return 0; + goto cleanup; } no_promisor_pack_found: @@ -123,8 +122,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data, rev_list.no_stderr = opt->quiet; if (start_command(&rev_list)) { - free(new_pack); - return error(_("Could not run 'git rev-list'")); + err = error(_("Could not run 'git rev-list'")); + goto cleanup; } sigchain_push(SIGPIPE, SIG_IGN); @@ -157,6 +156,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data, err = error_errno(_("failed to close rev-list's stdin")); sigchain_pop(SIGPIPE); + err = finish_command(&rev_list) || err; +cleanup: free(new_pack); - return finish_command(&rev_list) || err; + return err; } From patchwork Fri Dec 30 02:18:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F3EC4332F for ; Fri, 30 Dec 2022 02:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234387AbiL3CTi (ORCPT ); Thu, 29 Dec 2022 21:19:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234351AbiL3CTB (ORCPT ); Thu, 29 Dec 2022 21:19:01 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE96717055 for ; Thu, 29 Dec 2022 18:18:55 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id c34so22294667edf.0 for ; Thu, 29 Dec 2022 18:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y5vwVH4J9ZvUovy+1FgOcLrPlKbeuZn6CpUZGbs3HQc=; b=GYeV4PG19GCRy7LSJkJfH23ajTxwVja4Rz2rodDavi5b1T4v9ZUDfM5l3P7kBkmBue fvH2FzGUCQwopxym3alB++y8iALc7THMzrageCazCI+hslf0cEJzfYpU+Iey5KqAR+k9 kE3aUydYb/X4OSjJf9jfGYOApHv5g/sLP+DstiG0fXMMIG6cJjOsKrstsiO1IipHALSQ f1lhpL/DQHOEmVe6xA2Y8J8dgELzBZCY7J91GP/OHUAHZotW+HU+HTf7Wzr1qvAoICeb XgLSH9O5eFKppjvO81TCF1M1Z8+mLfxhSYKhQgR/ciQV0WA4LsUnD6BCKmMS+Un2zfhs MRtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y5vwVH4J9ZvUovy+1FgOcLrPlKbeuZn6CpUZGbs3HQc=; b=quLD0vKw0uV82M0tr79iOmK00gSXVDWyU+ncNhp5OvrauFpqZDVvrXB8pIKgDk8SqV Vw9CfV+dPxrTSoqH7vQdNNNYUU3ReZTt+lUtCdn0DObowxN/PodblsXMKi5Kejm+E3hT 84fJwZuw7/OV1U0fn1yxp6AhN/GzoZ79IouZ/SnWSAUg1faPovyZJzbEcgsmZDHJ8Aps h3+TXXHDG3k9h2vtC3EKbYXQrwLa90l3WZTJX/gOYFDvDBWhENF5B0oHpTqjuWVtfQmM Cv68XQqiLy5wBLTc8UwTC95k7mkk1WAE0E1fKigbpZO0BnWatyijtp56I/WHsrdhVc58 C6ZA== X-Gm-Message-State: AFqh2kp1PGRq5kgKfPqGwNeFfECQ4Oic7Ym6XS35fiUMEGn/zq4VgEjW raaAbxobmEBtjTf2/oIilt8SiqtTO+R3uQ== X-Google-Smtp-Source: AMrXdXs3WV7UqiqWWGfRbIoZB1JCXComFfTJXzY85bAbnCjsB85ggEQ8omBcvxsR8Vcf4rsJfV9Jyw== X-Received: by 2002:a05:6402:4518:b0:46c:b2a7:1e03 with SMTP id ez24-20020a056402451800b0046cb2a71e03mr22915998edb.36.1672366733921; Thu, 29 Dec 2022 18:18:53 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:53 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 16/20] object-file.c: release the "tag" in check_tag() Date: Fri, 30 Dec 2022 03:18:31 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us ever since c879daa2372 (Make hash-object more robust against malformed objects, 2011-02-05). With "HASH_FORMAT_CHECK" (used by "hash-object" and "replace") we'll parse tags into a throwaway variable on the stack, but weren't freeing the "item->tag" we might malloc() when doing so. The clearing that release_tag_memory() does for us is redundant here, but let's use it as-is anyway. It only has one other existing caller, which does need the tag to be cleared. Mark the tests that now pass in their entirety as passing under "SANITIZE=leak", which means we'll test them as part of the "linux-leaks" CI job. Signed-off-by: Ævar Arnfjörð Bjarmason --- object-file.c | 1 + t/t3800-mktag.sh | 1 + t/t5302-pack-index.sh | 2 ++ 3 files changed, 4 insertions(+) diff --git a/object-file.c b/object-file.c index c1b71c28347..53477a07469 100644 --- a/object-file.c +++ b/object-file.c @@ -2331,6 +2331,7 @@ static void check_tag(const void *buf, size_t size) memset(&t, 0, sizeof(t)); if (parse_tag_buffer(the_repository, &t, buf, size)) die(_("corrupt tag")); + release_tag_memory(&t); } static int index_mem(struct index_state *istate, diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index e3cf0ffbe59..d3e428ff46e 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -4,6 +4,7 @@ test_description='git mktag: tag object verify test' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh ########################################################### diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index b0095ab41d3..54b11f81c63 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -4,6 +4,8 @@ # test_description='pack index with 64-bit offsets and object CRC' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' From patchwork Fri Dec 30 02:18:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 135DBC4332F for ; Fri, 30 Dec 2022 02:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234350AbiL3CTo (ORCPT ); Thu, 29 Dec 2022 21:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234353AbiL3CTB (ORCPT ); Thu, 29 Dec 2022 21:19:01 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A74F917888 for ; Thu, 29 Dec 2022 18:18:56 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id u28so24034750edd.10 for ; Thu, 29 Dec 2022 18:18:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HdxqY8IQiB9zQE6L43tYA+GaKvhgdq23KkAZRaO1jWU=; b=g5ypJxV1MDiJ5qX0gI/ObRaWWmkGiEamdawSUVRYH+7TJ2kwLgCStyMzZMQIc+ovSs wrgPxhPtYKdJBcuVFRVE2lcw+UW2WIGvaM2dath6fNuKmENaStlJG79+1S2/nUMIQ8TA iXo686ZRcsX29mKmIrpGpYO+ekJMa3niqSpjO/CQEs/TRT3Nsko0BrOnGA25at2JUmDe 71TsDRIfuRng02nDPZQtzu0WbMFCo5S3Jj9J/5LKiEeIPscZ06VQKctN6fm/0PgENKTE Unnm4J0iVOhulKahDpl72fH803CZfxvhp/twltI3Zyz37q0dEoxIOhPszI4BvRJFGbpS zlbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HdxqY8IQiB9zQE6L43tYA+GaKvhgdq23KkAZRaO1jWU=; b=d+u6KJrpNU5uetsa1YiKASpCpbVYCzEUawbIyPJSXTh9xN5SA9lBUL30WkmgRvTeIt CdvS7brWnnsSMBE+ndxVmN9edZvEK3G5FSAONTugoVSPeiuf26ORa65XxWj0+VUfOSTI tP/Wg6XB5YTU9nYh547DtfxxMeOcJGkS4KRufC97JHDB8DJf78XFFxqwXonpUhRXzWKk oEw2nZySKy34OcHCZVIDjX89E7rSa6ZZiDCH0CItHftX6ycP+zBpxUVdtlceH+dtojj0 oALnrasBlQ9YTaFkLSLVwdLQPsUd8ma8oCZ0xnTJzHf10MSro5GEnblceyzgy0IEdXVU gk2Q== X-Gm-Message-State: AFqh2kqgqG2och0292v12EuyPeJq/iU8szH/8ntbfOSL5kMxQmjX71Fq 91aMvs88uFB9Je6D+RD1OODJqFivzVv03g== X-Google-Smtp-Source: AMrXdXteYj23GurDZB3YIibc7F9o1DmYWYKAgfzgICCG3RYGjiheRpvN8VcH456tfHRA959kc/6h6Q== X-Received: by 2002:a05:6402:1f0b:b0:467:7b2e:88a2 with SMTP id b11-20020a0564021f0b00b004677b2e88a2mr26188666edb.19.1672366734840; Thu, 29 Dec 2022 18:18:54 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:54 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 17/20] grep.c: refactor free_grep_patterns() Date: Fri, 30 Dec 2022 03:18:32 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor the free_grep_patterns() function to split out the freeing of the "struct grep_pat" it contains, right now we're only freeing the "pattern_list", but we should be freeing another member of the same type, which we'll do in the subsequent commit. Let's also replace the "return" if we don't have an "opt->pattern_expression" with a conditional call of free_pattern_expr(). Before db84376f981 (grep.c: remove "extended" in favor of "pattern_expression", fix segfault, 2022-10-11) the pattern here was: if (!x) return; free(y); But after the cleanup in db84376f981 (which was a narrow segfault fix, and thus avoided refactoring this) we ended up with: if (!x) return; free(x); Let's instead do: if (x) free(x); This doesn't matter for the subsequent change, but as we're refactoring this function let's make it easier to reason about, and to extend in the future, i.e. if we start to free free() members that come after "pattern_expression" in the "struct grep_opt". Signed-off-by: Ævar Arnfjörð Bjarmason --- grep.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/grep.c b/grep.c index 06eed694936..a4450df4559 100644 --- a/grep.c +++ b/grep.c @@ -769,11 +769,11 @@ static void free_pattern_expr(struct grep_expr *x) free(x); } -void free_grep_patterns(struct grep_opt *opt) +static void free_grep_pat(struct grep_pat *pattern) { struct grep_pat *p, *n; - for (p = opt->pattern_list; p; p = n) { + for (p = pattern; p; p = n) { n = p->next; switch (p->token) { case GREP_PATTERN: /* atom */ @@ -790,10 +790,14 @@ void free_grep_patterns(struct grep_opt *opt) } free(p); } +} - if (!opt->pattern_expression) - return; - free_pattern_expr(opt->pattern_expression); +void free_grep_patterns(struct grep_opt *opt) +{ + free_grep_pat(opt->pattern_list); + + if (opt->pattern_expression) + free_pattern_expr(opt->pattern_expression); } static const char *end_of_line(const char *cp, unsigned long *left) From patchwork Fri Dec 30 02:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2FA0C3DA7A for ; Fri, 30 Dec 2022 02:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234406AbiL3CTt (ORCPT ); Thu, 29 Dec 2022 21:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234358AbiL3CTE (ORCPT ); Thu, 29 Dec 2022 21:19:04 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6DED17882 for ; Thu, 29 Dec 2022 18:18:57 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id u28so24034778edd.10 for ; Thu, 29 Dec 2022 18:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wh6Ftz+AHRDRNG/GOzECG9eiAz7D5GORQnv+60g4Vqs=; b=UM3v2nT2Zi5Fr0M3RJZUgMPbqU33WFt5NuBRU2EUjSVjK+HJChJFQqCkw48+Sj+ZKU +Wv638oCQlA8KrnfCbRwbQYAzSCbFbcf9tAZ1CrRj266FlHyKHFTQNck4HD9yu3p3Ssw ZFB4sg8h08XS6G9Y1oLQB1i8t1xR+bzIzqoeo3rAXhXdqqPGUU9d9YFr7CNYdBtT3PR0 57oq48vJT1POMiDYYNEeBY3VU2RHg/zgjgOnK7CRMAYSzAVjdetmST1jrEcLJsJi5/C3 5qzOmavz/tROZt+Z0w0InJw8MBZyh3pG/50o9B348D2Ar9wHLxOJDlIyCEpLQprg3cTj Ynxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wh6Ftz+AHRDRNG/GOzECG9eiAz7D5GORQnv+60g4Vqs=; b=5O8T5uAi6vjJAht1FUKkj+H3hC/aIW50MW477v2l1kU9wgI4QbL3nIqzHCeiwlEYEd P1IebANvaWFcEUfB5GlaOEypvL+cjF0r7SaIuAwVAhQe6r/WULFIbxvIILwhQ7EMVID0 2oLajKcyCFzbcnAzybC2HTj+NncQ86q8rfbyPIktRs9W202E0Twm+/ejaLxPArZSSYry pL+f9jpH3Gp5FoAVFhSz5xLmoJ9XuFxeKqjamqHzJJF6O7RsCaoxac9cfyUSCB61xRya noQMy85pvs0O/6wSlWXr3xtMNVbm3XHx72W1qpHwiWk1+w+bs4bYAub6t/kEM2lPZ952 zkFg== X-Gm-Message-State: AFqh2kp7pEcnC34g16KFt6aB74FbQI374Dupvt+W7Dm0PEZ/NXxp/CUk nc9EX4pxJ5STQ2WbMj5J5+MEsqfWQBN5VA== X-Google-Smtp-Source: AMrXdXuHSqj9KTrpMT7hC8R7YoCgOh/EcBFrjCCnLJ8by1wXm4nB0RNzJ1cwis0oeafjDloj7pde+w== X-Received: by 2002:a50:ee8c:0:b0:47e:6b3c:931a with SMTP id f12-20020a50ee8c000000b0047e6b3c931amr25226245edr.10.1672366735812; Thu, 29 Dec 2022 18:18:55 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:55 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 18/20] grep API: plug memory leaks by freeing "header_list" Date: Fri, 30 Dec 2022 03:18:33 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the "header_list" struct member was added in [1] it wasn't made to free the list using loop added for the adjacent "pattern_list" member, see [2] for when we started freeing it. This makes e.g. this command leak-free when run on git.git: ./git -P log -1 --color=always --author=A origin/master 1. 80235ba79ef ("log --author=me --grep=it" should find intersection, not union, 2010-01-17) 2. b48fb5b6a95 (grep: free expressions and patterns when done., 2006-09-27) Signed-off-by: Ævar Arnfjörð Bjarmason --- grep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grep.c b/grep.c index a4450df4559..c908535e0d8 100644 --- a/grep.c +++ b/grep.c @@ -795,6 +795,7 @@ static void free_grep_pat(struct grep_pat *pattern) void free_grep_patterns(struct grep_opt *opt) { free_grep_pat(opt->pattern_list); + free_grep_pat(opt->header_list); if (opt->pattern_expression) free_pattern_expr(opt->pattern_expression); From patchwork Fri Dec 30 02:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43162C3DA79 for ; Fri, 30 Dec 2022 02:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbiL3CTl (ORCPT ); Thu, 29 Dec 2022 21:19:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbiL3CTB (ORCPT ); Thu, 29 Dec 2022 21:19:01 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B41531704D for ; Thu, 29 Dec 2022 18:18:57 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id l29so21832785edj.7 for ; Thu, 29 Dec 2022 18:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7nwErfZ9e0+06NjDReS67pXkkZGuuUIAdXmxQ+5kqvE=; b=WFkMLk41rqntnEz318jhuOTCCOb5pw67pmI+cSDUnYjEywf5SAI4iXEyxx8kuPtAIK IMeT57Jt71R/1KnbhmlIFBvXS/uM8/RftIyYikOwPMGqeprjijnMP0kAqaGXoGNru7fo 3o8jCUV4GwUePlDSIH05B9ciMKkkX4QnIB+Oe4mM2KFuxdgwFOQbIf1okMMfW9vf1+Qp XPEjm5Phvu7SDpA4GllZDUM4PvG9MABigicH6XpRkbV9asDYUWOp67YgY3T5GNkqqZb8 JoLysrpJuaP+veouEM5s6zDZZaD6kRq30aJBZqPraxe7eosZF9c1A9wn2oMDr+3yvrOv 8H6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7nwErfZ9e0+06NjDReS67pXkkZGuuUIAdXmxQ+5kqvE=; b=yTWtVHKNJ5uLWX6fC3FurOyqeCUhAbQT9ap7suasiqegs6L1hVIMj607OnnwQI4mAf QXmT9vKwfIb1UdL8i8kbGnakS1pude2MtAnfFB2Nh+EzwA6jMf0SmH7njn1CZzYqoAMd cQcQY0lXK8Y8XJkChGtjGdKnasD3zbDscA3qWgWbqb03x0z2QO6bwrqeaHFRe2zCf+A3 kzQawEg1u1JY5B0vbhahR0vF958HI9uSLYTdTW842cW+YlVmi5N1TJZ/CkUp3UIUah0C roFXyTD8ttv0UOiEzlfVYb0JA51dWqXGMdR+Yk/2FTjUMvF3G0LPX15eZAaxsKs6+bBB o33g== X-Gm-Message-State: AFqh2ko5X/vpTVSuiA7E8eywK2Wz7tqk0ZpzRDANdGdtnuDPPcwMLM3v ghkAjXKxXRIrUyFdkq88Fr7nj/l/NNHqQw== X-Google-Smtp-Source: AMrXdXu008S9q90PTYQBvhEBfBi+IK5HsarkIM2u63I+rEw1/CQtsHYzJsDh7wupwTj1uvYXE/XN9A== X-Received: by 2002:aa7:cd04:0:b0:46b:cb37:117b with SMTP id b4-20020aa7cd04000000b0046bcb37117bmr22802830edw.39.1672366736989; Thu, 29 Dec 2022 18:18:56 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:56 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 19/20] receive-pack: free() the "ref_name" in "struct command" Date: Fri, 30 Dec 2022 03:18:34 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us since this code was introduced in 575f497456e (Add first cut at "git-receive-pack", 2005-06-29), see eb1af2df0b1 (git-receive-pack: start parsing ref update commands, 2005-06-29) for the later change that refactored the code to add the "ref_name" member. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/receive-pack.c | 10 ++++++++++ t/t5405-send-pack-rewind.sh | 1 + t/t5406-remote-rejects.sh | 1 + t/t5507-remote-environment.sh | 2 ++ t/t5522-pull-symlink.sh | 1 + t/t5527-fetch-odd-refs.sh | 1 + t/t5705-session-id-in-capabilities.sh | 1 + 7 files changed, 17 insertions(+) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a90af303630..451bad776c6 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2032,6 +2032,15 @@ static struct command **queue_command(struct command **tail, return &cmd->next; } +static void free_commands(struct command *commands) +{ + while (commands) { + struct command *next = commands->next; + free(commands); + commands = next; + } +} + static void queue_commands_from_cert(struct command **tail, struct strbuf *push_cert) { @@ -2569,6 +2578,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) run_receive_hook(commands, "post-receive", 1, &push_options); run_update_post_hook(commands); + free_commands(commands); string_list_clear(&push_options, 0); if (auto_gc) { struct child_process proc = CHILD_PROCESS_INIT; diff --git a/t/t5405-send-pack-rewind.sh b/t/t5405-send-pack-rewind.sh index 11f03239a06..1686ac13aa6 100755 --- a/t/t5405-send-pack-rewind.sh +++ b/t/t5405-send-pack-rewind.sh @@ -5,6 +5,7 @@ test_description='forced push to replace commit we do not have' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh index dcbeb420827..d6a99466338 100755 --- a/t/t5406-remote-rejects.sh +++ b/t/t5406-remote-rejects.sh @@ -2,6 +2,7 @@ test_description='remote push rejects are reported by client' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5507-remote-environment.sh b/t/t5507-remote-environment.sh index e6149295b18..c6a6957c500 100755 --- a/t/t5507-remote-environment.sh +++ b/t/t5507-remote-environment.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check environment showed to remote side of transports' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'set up "remote" push situation' ' diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index bcff460d0a2..394bc60cb8e 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -2,6 +2,7 @@ test_description='pulling from symlinked subdir' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # The scenario we are building: diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh index e2770e4541f..98ece27c6a0 100755 --- a/t/t5527-fetch-odd-refs.sh +++ b/t/t5527-fetch-odd-refs.sh @@ -4,6 +4,7 @@ test_description='test fetching of oddly-named refs' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # afterwards we will have: diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index ed38c76c290..b8a722ec27e 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -2,6 +2,7 @@ test_description='session ID in capabilities' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh REPO="$(pwd)/repo" From patchwork Fri Dec 30 02:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13084031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61770C4332F for ; Fri, 30 Dec 2022 02:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234407AbiL3CTv (ORCPT ); Thu, 29 Dec 2022 21:19:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234293AbiL3CTJ (ORCPT ); Thu, 29 Dec 2022 21:19:09 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E28518381 for ; Thu, 29 Dec 2022 18:18:59 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id u18so27479027eda.9 for ; Thu, 29 Dec 2022 18:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mU8tTIWIarld+XBLkKwAevtMdAA0ewGRb+ylIvC3+vQ=; b=dpzZ1CWKmDR7/gcYY4YQfQrWEfVlp78jGvQeUIbifmgKU5XQdqY7+mMnamjC/Q748o kMDHNNHvK7N6Er74sJYqf9izAwbLlPHHNk2GmPXQ765QOSAHcrAOr+c7+VdtSl3tJRgF EFl1XjGMO8aWnBtdzm/so3Gn8OcmVtdVcLPoDwBpqZLBisCWIAFfcIvRFnysCU68cjXa hHYqA/o61Av55wD/NOtrUTpCNSvD+sVhKwQ/ZkNs6FBIhsZaL7snkQ8xqf7pbrL8MjHR rGdd1PnnWqaFZ77gqXhR7GZrPB9+k7yOcQQyQ2a29OOqAj61Jmkd8QuvMSJts8pb2Uf/ jJdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mU8tTIWIarld+XBLkKwAevtMdAA0ewGRb+ylIvC3+vQ=; b=VX95DWmkwAZsMQUuUoByz2+24r/lN5dizu3NDvelbNBbl3DAVuXPprW9GmSnszvvUA FYBVqnBsxR1g8TBfEWVXJlyTeAJ8ihPzlZOEL/pziyuvSV4zVticjQMDx8n+hB+lDSzS gy+Z2t2g7pedYRj3HZii0sXdmHMTQboKnlUsnEP5G0mQvaW6JMo7qaWC0iioO9qZNP3E dKWk8I2FCZCTVtEXuWdV3q+dJI+SBqIw8a010DTrvKruiK6xiVuwkUUzGKRuATPP3CS9 TM04h14BqwdNNYDawRytzVrBiStaAMSzmom3iiOPyS7Gk7bXDT9Q54aHEJYCdnpksfwG fB4Q== X-Gm-Message-State: AFqh2kqfSUQVdScvm2taghKLUvrDRHrch+HaFGsRLiGJ8N416zBHTI2X UtPNXq4gqpnDqJV55v8y2NXqUKaKkhC5VQ== X-Google-Smtp-Source: AMrXdXtffSc/IBC3nftitScLWkLXUdxDghmYt+tjVargQ6hvU0iSnbpAfKJwYQfSZLyBsvedewjyaA== X-Received: by 2002:aa7:ccc2:0:b0:477:8ab8:43e0 with SMTP id y2-20020aa7ccc2000000b004778ab843e0mr25396532edt.2.1672366737824; Thu, 29 Dec 2022 18:18:57 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id ay15-20020a056402202f00b0046dd0c2a08esm8861991edb.36.2022.12.29.18.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 18:18:57 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 20/20] push: free_refs() the "local_refs" in set_refspecs() Date: Fri, 30 Dec 2022 03:18:35 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1153.g589e4efe9dc In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us since this code was added in ca02465b413 (push: use remote.$name.push as a refmap, 2013-12-03). Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/push.c | 1 + t/t1416-ref-transaction-hooks.sh | 1 + t/t5504-fetch-receive-strict.sh | 1 + t/t5523-push-upstream.sh | 1 + t/t5529-push-errors.sh | 2 ++ t/t5546-receive-limits.sh | 2 ++ t/t5547-push-quarantine.sh | 2 ++ t/t5606-clone-options.sh | 1 + t/t5810-proto-disable-local.sh | 2 ++ t/t5813-proto-disable-ssh.sh | 2 ++ t/t7409-submodule-detached-work-tree.sh | 1 + t/t7416-submodule-dash-url.sh | 2 ++ t/t7450-bad-git-dotfiles.sh | 2 ++ 13 files changed, 20 insertions(+) diff --git a/builtin/push.c b/builtin/push.c index 60ac8017e52..f48e4c6a856 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -129,6 +129,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo) } else refspec_append(&rs, ref); } + free_refs(local_refs); } static int push_url_of_remote(struct remote *remote, const char ***url_p) diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh index 27731722a5b..b32ca798f9f 100755 --- a/t/t1416-ref-transaction-hooks.sh +++ b/t/t1416-ref-transaction-hooks.sh @@ -5,6 +5,7 @@ test_description='reference transaction hooks' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index ac4099ca893..14e8af1f3b7 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -4,6 +4,7 @@ test_description='fetch/receive strict mode' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup and inject "corrupt or missing" object' ' diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh index fdb42920564..c9acc076353 100755 --- a/t/t5523-push-upstream.sh +++ b/t/t5523-push-upstream.sh @@ -4,6 +4,7 @@ test_description='push with --set-upstream' 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-terminal.sh diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh index ce85fd30ad1..0247137cb36 100755 --- a/t/t5529-push-errors.sh +++ b/t/t5529-push-errors.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='detect some push errors early (before contacting remote)' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup commits' ' diff --git a/t/t5546-receive-limits.sh b/t/t5546-receive-limits.sh index 0b0e987fdb7..eed3c9d81ab 100755 --- a/t/t5546-receive-limits.sh +++ b/t/t5546-receive-limits.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check receive input limits' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Let's run tests with different unpack limits: 1 and 10000 diff --git a/t/t5547-push-quarantine.sh b/t/t5547-push-quarantine.sh index 1876fb34e51..9f899b8c7d7 100755 --- a/t/t5547-push-quarantine.sh +++ b/t/t5547-push-quarantine.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check quarantine of objects during push' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'create picky dest repo' ' diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index cf221e92c4d..27f9f776389 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -4,6 +4,7 @@ test_description='basic clone options' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5810-proto-disable-local.sh b/t/t5810-proto-disable-local.sh index c1ef99b85c2..862610256fb 100755 --- a/t/t5810-proto-disable-local.sh +++ b/t/t5810-proto-disable-local.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test disabling of local paths in clone/fetch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-proto-disable.sh" diff --git a/t/t5813-proto-disable-ssh.sh b/t/t5813-proto-disable-ssh.sh index 3f084ee3065..2e975dc70ec 100755 --- a/t/t5813-proto-disable-ssh.sh +++ b/t/t5813-proto-disable-ssh.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test disabling of git-over-ssh in clone/fetch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-proto-disable.sh" diff --git a/t/t7409-submodule-detached-work-tree.sh b/t/t7409-submodule-detached-work-tree.sh index 374ed481e9c..574a6fc526e 100755 --- a/t/t7409-submodule-detached-work-tree.sh +++ b/t/t7409-submodule-detached-work-tree.sh @@ -13,6 +13,7 @@ TEST_NO_CREATE_REPO=1 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh index 3ebd9859814..7cf72b9a076 100755 --- a/t/t7416-submodule-dash-url.sh +++ b/t/t7416-submodule-dash-url.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check handling of disallowed .gitmodule urls' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7450-bad-git-dotfiles.sh b/t/t7450-bad-git-dotfiles.sh index ba1f569bcbb..0d0c3f2c683 100755 --- a/t/t7450-bad-git-dotfiles.sh +++ b/t/t7450-bad-git-dotfiles.sh @@ -12,6 +12,8 @@ Such as: - symlinked .gitmodules, etc ' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-pack.sh