From patchwork Tue Jan 17 17:11:06 2023 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: 13104898 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 BFAC7C3DA78 for ; Tue, 17 Jan 2023 17:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233241AbjAQRLn (ORCPT ); Tue, 17 Jan 2023 12:11:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234165AbjAQRLd (ORCPT ); Tue, 17 Jan 2023 12:11:33 -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 234FE33454 for ; Tue, 17 Jan 2023 09:11:29 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id 18so46001135edw.7 for ; Tue, 17 Jan 2023 09:11:29 -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=79enDUK9Un78iCLGnZFE0UeOMxA4gUH483+8+cNxVqk=; b=WemPh/HwV6gjeyuND4wFujqmJQ5nHMe3ffixgZAt6q+qOYIjOVr2BYNC3ZqmtQ5LMW t5ynzmEzqZX3tGi+hY/v6onEmasRhUwsqPDAQs5WIojKlmYPVpsqBucoqsRb5q9llB/J CGvCQif3XNcWTLfZeQ09K+9kjoOlLEcxjBI8kgJ50OCzmz8ZZnZvVbZg+j/7+xoJ9Dce Zt1isoLupi2yWrUcQimTgkMV+aUxZwT6c6cxviPpw8xdUuS6sVX8GYzphr2Q74oE0I/R QHi6hK+EOKp0MrzvWXU7OieD958yFpEcpkPQU8Zv2MGqXlPXCZiiao5YkPYCvDguQlf9 y1AA== 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=79enDUK9Un78iCLGnZFE0UeOMxA4gUH483+8+cNxVqk=; b=jaV5TINYirxw1Her0LAhPL+sNTE0Wz7UrTYJ7hfpivhie/sDQjKy8jqkGRFevZ0VWT xFTxciTNneVAlZ8VIMJY7IzKPpuHS4i1f9q+RUcP1dE9Wtgu+LIRmumEDrHzKKGAMuY0 SC/vxZm8dMnMG/oiwY7Ybwy0gdoROIa+78crKTjDB0GMbZEIrdoXHdJw2hOcF6AHgEI6 OzBgzsDNivbbH3ATrfoJbSs4NLwjXwBtTBjg2+KUNNwhX09yzmWWcNVKuZY+SHuiKxqB 6tv0J7w0RFCaCK/adHa+07hoU+zKBX/o74nuif8eBvwT6jii64abaijyFUNh2suApyuN L/Eg== X-Gm-Message-State: AFqh2koY8uWk4KElH0h1uc0AsRSCMP7TxcwHm55JE7uX8xFqcRPRzvtg PqwrSHAq3F2gcbwsSgNeI29SRBjBJFlZXg== X-Google-Smtp-Source: AMrXdXvsY3hUZAn8yDbb34aRkq4hMxfV7ERhgO0epNdDiG1DfDan8C5FkWh2e+Aw8QkG0kT8dsvXew== X-Received: by 2002:a05:6402:2289:b0:498:f82c:7068 with SMTP id cw9-20020a056402228900b00498f82c7068mr2933667edb.35.1673975487717; Tue, 17 Jan 2023 09:11:27 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:27 -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 v4 01/19] tests: mark tests as passing with SANITIZE=leak Date: Tue, 17 Jan 2023 18:11:06 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 7cf80bf66a6..70389fa2ebb 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 Tue Jan 17 17:11:07 2023 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: 13104899 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 E0A28C3DA78 for ; Tue, 17 Jan 2023 17:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234333AbjAQRLq (ORCPT ); Tue, 17 Jan 2023 12:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234139AbjAQRLd (ORCPT ); Tue, 17 Jan 2023 12:11:33 -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 2392A34569 for ; Tue, 17 Jan 2023 09:11:30 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id m21so45998164edc.3 for ; Tue, 17 Jan 2023 09:11:30 -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=5HgRUV8vc+1/isXemg17KC16Xl/Kcpdk3WdYy0RAdlM=; b=GV+SDmHhYqPN/bkBwFvzLjlpdvh2ef+ReOq4GiqA+bHF+uzylWSwq7BhR9npBAjcOb 1rISyy4KKtHaq1s4jmtjscLoPbvQsqFFBHY3REQDWw2yhi/kOga9Y1lo2knDi6HmUoB/ mmXVaftE3vLjTy6gZyUUln06K9/1ScNHFeUVRMnQq6RpwAPcVsQm3YzFeGGhSvgTI1qW E0lh0MW1O4FGs78DZzopGTUHb+fLYiHayEX9v8IFS3b4tZLLY6kQX6F1vmmwt5o1UeY8 8m+TYVuypwZw5FvAwRLzARwYbaLWhYyF5qHvt4428ftH1MAhyQrjiRYxIhrc4keuazsD w6bg== 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=5HgRUV8vc+1/isXemg17KC16Xl/Kcpdk3WdYy0RAdlM=; b=yEzZHCHnNYKdgSvpkg5W67MCHRr+HeFumv3WeoT65QplkSVQIhyC+45NfM0dedk7QP PwzIEPG0ewJUUAWYYAh8Bljj5JXA5cGK2pHHcc3ty3KnpU8hYv3mvJhRfAd6lNYwh2s9 iKCpNB4wEx51yfm4C1C3uV+v8ZQWCpCByR4aTMOcvYjUtFcqG9hkrY3zOWPuIhn6kCQs T+QRD5MOlH+PazUIST5EtIxfD93jYC7YEOSUd49qo1d8SRXi/hmyEd47QC+MRWaDzdca YyQwI6fbVKdzyD3KNJDQnXOoeg90tIk8z08dKsTCOjx6p90RWwA3jg2R90OpE/UABn3/ Zd+Q== X-Gm-Message-State: AFqh2kqY6BcpzjG32VVt8XFT64vaWUS3QiINMjNxHLVh94vYjJihQRjl yBy9agdHhzioHpUUkAzMMmhuDi+NaJ+oAA== X-Google-Smtp-Source: AMrXdXuwCOYbHAGwTKVGfOnMz2EeHih6qBSPuS+/gxIvG5pdIf9el0y7f4Qb018VcK4bj0oquYfXOg== X-Received: by 2002:aa7:cd8f:0:b0:499:4130:fae with SMTP id x15-20020aa7cd8f000000b0049941300faemr3240171edv.10.1673975488482; Tue, 17 Jan 2023 09:11:28 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:27 -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 v4 02/19] bundle.c: don't leak the "args" in the "struct child_process" Date: Tue, 17 Jan 2023 18:11:07 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:08 2023 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: 13104896 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 996B2C3DA78 for ; Tue, 17 Jan 2023 17:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234233AbjAQRLg (ORCPT ); Tue, 17 Jan 2023 12:11:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234118AbjAQRLd (ORCPT ); Tue, 17 Jan 2023 12:11:33 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2382134562 for ; Tue, 17 Jan 2023 09:11:30 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id v10so44794358edi.8 for ; Tue, 17 Jan 2023 09:11:30 -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=EaSBqhwqTjB2hNqh3m5vH/RC9JqHAeewvEHTqaNglZE=; b=Xqj73dKzaj64Jl8Q0t4AwLG+t2Hgb+Ic1lwGSmz9ZTEJDuaoWd5cb4iHHXAbL5u9HP MgzspGtq+9k6zznsOcjnS3N3kAE1ilFxmlcB3n3ljTWc4awpjzryBGZqOVrDHjrbnZAd bTO2+dNj+XcDjdtcZZzGd5pSV/ixURWodKu2UMm/w+hEaQ8UrcxtKdYDKdXcgOlCpkWr sZqiYDaa8kxJhDq9SkM4KUm/RIvMa3CnM9i+b/PaZbKomXYgdwph1h3KtBwUb91Zfbc4 I3GKLPzSzu8GFp82CCUr89SJP2/X5HF3uQnXg3x58eXxJ93xc2ZyVC/a6yiBdMoXuuek 7uKw== 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=EaSBqhwqTjB2hNqh3m5vH/RC9JqHAeewvEHTqaNglZE=; b=Z5HMYdLKQnb1yuR5d/VdGAa5tUkn/Pdvk0ETo83bW84eBXOfh3T2HL5MbzASke97Tk f9LQck1Ard+NZEEDS1mMdZRxLi5zGuME6PT5qSGZrDTqXNDoTkdGl2FvofNCpi0AIfJU FSoqDZ5sXM5mQn1d3N2vK6Lryxq4F67BdQHCC4ZM6XJ+TmVhpAVjhqIlYm5Fl200CmbR 52mUSykfWXTQZUhxmdn9hMNvxgegX0KbSOHRMMibIT8fPjY8/TAm5Q3yCx1GeUaPnPIN 8KmFbzhozgWg+GXsGvR6VcRSHB1juBZGDfBFEwA8L+mE32HQ8qrBQjSeuxB6oMsiJxnF QiQA== X-Gm-Message-State: AFqh2koi7tITq8GYjZi66aVyzEDVfDvdvElnLJ7+C5d6fSg2rgjK0ehh bNQ+2gUpHTWovkWw35scZl/R46CEvqxtng== X-Google-Smtp-Source: AMrXdXulKnZU8taBHuOTEmn/roysaAzF+OrF+BLfZez+dMKHkiC4SljmRh13I1ovip2ajeP1x/+t4g== X-Received: by 2002:a05:6402:2b92:b0:45a:7d2:9b35 with SMTP id fj18-20020a0564022b9200b0045a07d29b35mr3985412edb.0.1673975489233; Tue, 17 Jan 2023 09:11:29 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:28 -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 v4 03/19] commit-graph: use free_commit_graph() instead of UNLEAK() Date: Tue, 17 Jan 2023 18:11:08 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:09 2023 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: 13104897 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 B238FC3DA78 for ; Tue, 17 Jan 2023 17:11:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbjAQRLk (ORCPT ); Tue, 17 Jan 2023 12:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234102AbjAQRLd (ORCPT ); Tue, 17 Jan 2023 12:11:33 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA23C3457D for ; Tue, 17 Jan 2023 09:11:31 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id y19so12432671edc.2 for ; Tue, 17 Jan 2023 09:11:31 -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=QRTnwPrbrV7ma7a3OZWCZwFiOWUu4067NVK87XmGZ6E=; b=eDUMPKolei62UAmiye8uJHPeGIReK4w3qDlUClS5lhyqHhXtO+h3eQBTQRX7MdJePA 5ADvfp9AIdUKpRc0f7zrjQOp8nf54l3hSTPgL5hBME+r3w89WEsMKHNR921OAeT8u8Qu Qz2LPVLBBO8xv5x5DjhJAWwUukKzxNFp76TzzkeiLrehEhHERi+vc5rZyFPgAt27gBcU 6ydLPFZlHWy+UeU3o7iv+nZqd4jh612Ze+0yCgD2RN8UqS21RJPz0VUS7tbpqBuVeBEB Nq7nvcaXvOP3ITmkZVvT9kVzfwyA6O0KLrJqKWdjjllj/e5t0YMNNO9uvPBcYeqQA4EE LMjQ== 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=QRTnwPrbrV7ma7a3OZWCZwFiOWUu4067NVK87XmGZ6E=; b=RWYn97NhasWkIT0niAlqrqZP44WHvUQWOPTnp7k5cZw0huWhcgO8GY5oP2zr4GoGgS 0yeqGNppxW6XIGeTeqnZg5qRhNRYzj0IQwBfdTy2FwVly0dyOY0/sW8Q0JI38voq4vhD JebQEjGLFq0MPWBgRBgWrviM/Md21gwfVThuwcR5+FtdtgB6A4JDwGxovA/nik+i3J+a iWaBUThoR1rskFj0wE5qq3ZR/lam1TFYknegzfE1arVeYl+fP85OxsBEkcEKWXWuGCSw +ar+YIkTgnAmr4gCHE+s4WiM0B8IvoP/Ic4Db3EhdIuB2eY7HneQkOuGjL/hoEw3eZml tpPA== X-Gm-Message-State: AFqh2ko2HEqTlcPGKlzxf18B1CQ4lsBHOk0Lu9UU4L9Gv+DJ3f7Wkd75 3jfGxJ0plnTzpWiRIA6n3wEWjPDqCgp2jQ== X-Google-Smtp-Source: AMrXdXv0I9fIrtSQJti5pde+gE1Oil8pN+K6rHnWH+JeGWTG5fzVyThMkaS8+gvbaC8Y+rWS6bfw+Q== X-Received: by 2002:a05:6402:159:b0:49d:a87f:ba7b with SMTP id s25-20020a056402015900b0049da87fba7bmr3793320edu.39.1673975490033; Tue, 17 Jan 2023 09:11:30 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:29 -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 v4 04/19] clone: use free() instead of UNLEAK() Date: Tue, 17 Jan 2023 18:11:09 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 5453ba5277f..ba82f5e4108 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); @@ -1413,7 +1414,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 Tue Jan 17 17:11:10 2023 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: 13104900 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 4FF43C54E76 for ; Tue, 17 Jan 2023 17:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbjAQRLx (ORCPT ); Tue, 17 Jan 2023 12:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234178AbjAQRLe (ORCPT ); Tue, 17 Jan 2023 12:11:34 -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 6CF37367D7 for ; Tue, 17 Jan 2023 09:11:32 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id s3so7849157edd.4 for ; Tue, 17 Jan 2023 09:11:32 -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=cG+7ZZwi7C15rKfBHpcosgJoEHQ/85pRKJLqCcfbtc0=; b=AwPqlrfgvc42yhjf520o/EEFasIlxoaML9FLTR+xQl0FEg+M8uI9lf6G6p/1YmwbJJ lUp261M91tpKXqIM9hfLAYjsZXziLpZMcb3uJE3wLlOV8PbAxT/GeO6ctpN3BQFfqB4v 4klXQKi83hV9T3CvCn3s15OTuoltsAqGJxcdeRwBZHc9QsghhDGj8863IqrINBO25rBr r8vaLfNtK99LCsmva5RWpLjYxKYiWJXYHk2xV8vS9u/aJMyLYV8J4CrbE0OGwHhiYVQ9 5OE70pJDRjRBvyX5868U5ln0pBw9RIOUasPmsnkgE0f2kEd4gASwsnfgdY/gn15I09H9 XrrQ== 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=cG+7ZZwi7C15rKfBHpcosgJoEHQ/85pRKJLqCcfbtc0=; b=0Wt9+lDLHYClGH7JDlvMzPD1NWoRe0To5qxRYwTIbNhTnGV8+6QDGDwMYDWh7V8SZM qixTBMkGkijSlIfoQLJnegra9QRJYyxd+DdO2QlnY1ovcT2lHhqdl4GofOr5i5iL+tHl a/T0wYASsQm95dg3OZkWXskkqF7WSicoEmHQK/mMuU/5ttHf0bGhcSpFasad08qDVlwT wmP3krR70miiIPKos/vfqBTSqTyS4L8/sNq39vTl1ADxGHFX1zYjritp22+Lv1gvI8cf WVQ1ONrZDnJ5zSz77N7XZamtu7XiHfXx0l3IZ3/RLgrEKuQ+fNGZYChjj1wg/skZ2Sjp VRMw== X-Gm-Message-State: AFqh2krXzED4rav/nGJ6LLm3vgogvDcsiC1dBAZFGiDm3RWLg0i8ZTuG diYbXYBsIyRL1BDv5x2PO68br7NfatAR4A== X-Google-Smtp-Source: AMrXdXtuRlAaLyeVuX6sQ2GBfCBLe0o7jR1fIvuwWQGFU6O06ZndbOj/DrHGLl6XHILXpCn6VZA6oA== X-Received: by 2002:a05:6402:4d6:b0:46c:6ed1:83ac with SMTP id n22-20020a05640204d600b0046c6ed183acmr3912994edw.9.1673975490716; Tue, 17 Jan 2023 09:11:30 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:30 -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 v4 05/19] various: add missing clear_pathspec(), fix leaks Date: Tue, 17 Jan 2023 18:11:10 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:11 2023 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: 13104901 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 324BEC3DA78 for ; Tue, 17 Jan 2023 17:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234252AbjAQRL4 (ORCPT ); Tue, 17 Jan 2023 12:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234182AbjAQRLe (ORCPT ); Tue, 17 Jan 2023 12:11:34 -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 13B6C33452 for ; Tue, 17 Jan 2023 09:11:33 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id x10so43143426edd.10 for ; Tue, 17 Jan 2023 09:11:33 -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=JJsc2mByCTaVzvS4IrvPa5rvQz9EYF3b31Yl3yAfz8k=; b=Y8JDF+sl/MoPZaIWoyLR5U4SXWIP6GKIcK1+qJVw+ybI392/7sVks49P+byZIaWiv8 7hc4+B2fKho3IVfrdO7InhpGf1BlGz2VyrqKTQlzRvltHldAi5srOvnEsDovyV3sFtDn alI9+9rdExrH/Dqr4eO5v0jNVQOvaWje/qdlk8JwAvTjCwEzJoNSCpuq59pPYRrI1a8n kZrlgVGZnsTtvxB3Niad/hhoJx+qtYomuB0dOFixgIux/7CTb8de5bCJqUptFoN/k9DC 6GorkMDMdBi9rFFmRc3Uggelg+cLU7tyvpsyRhLOSIbI45Yb2e+MxKvDRr5pqTybNZFl Pnlw== 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=JJsc2mByCTaVzvS4IrvPa5rvQz9EYF3b31Yl3yAfz8k=; b=Wb45s8bghtW9dB1kQ2kR4OJMorAAsDtuGc3iaF2a1atdCapPvncvEklnYm4+qDETC5 CathmpWNYwnpLPfEHprj0iCVMjONl3iCJGc9WJIdKNxpXxkLc4s0Ht/cInH0EtKf+2Vd Gt+mzBPH4ZkPENltB1iUyV0eqbD6mXC5HVCYDlqniXaf5x814ByIml0yfNXzo6PgogHT xs0Q+DuKG6rISBcM0iacBJlNsi8yA54obCEypyAEVPHR9mSMjGBlJRb2YMiBztgEyz+6 niDfCMlhV3QMxzKRFmWsw9l4QPm56BX2egSBnJrXzvsls4GmbwrOS/Bjs/NRwS0wWan6 4/Dg== X-Gm-Message-State: AFqh2kpjmrg0Jv4SUhhZHguwGq/FUbuHIkORH6blsJcbhn+fkG7uThSh ldNdqH4fFNadbIryCnIXTPOhBwIsbQpJ2A== X-Google-Smtp-Source: AMrXdXutxUzX1NIjVhVEj8YgJHvJzgCPtvU1B4J0VOqRRNNnmxBx5sDuHlc/E3m35SNFrwc/RSzWHQ== X-Received: by 2002:aa7:c709:0:b0:499:ef31:3549 with SMTP id i9-20020aa7c709000000b00499ef313549mr17125830edq.6.1673975491400; Tue, 17 Jan 2023 09:11:31 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:30 -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 v4 06/19] name-rev: don't xstrdup() an already dup'd string Date: Tue, 17 Jan 2023 18:11:11 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:12 2023 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: 13104902 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 83F6FC6379F for ; Tue, 17 Jan 2023 17:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233911AbjAQRMB (ORCPT ); Tue, 17 Jan 2023 12:12:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234198AbjAQRLf (ORCPT ); Tue, 17 Jan 2023 12:11:35 -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 DB08C2ED6F for ; Tue, 17 Jan 2023 09:11:33 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id z11so46042605ede.1 for ; Tue, 17 Jan 2023 09:11:33 -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=qQ175NIebX6yUupAijy4xhJCiVhtfT9Z75MHK7wrUL8=; b=B/edhiQEfz6XmDwHhBos9Dthcta1s2hte/IUjOOvAHcg/yCNrtY0cG8W7lqgy4XG/7 drp816OS2qe8J+DHfH2TcWRfwufYaBR/WYNd9YQW73dmD1dZeCCX6vyBgt5YErstdf4k B3cQTvI0oAPzMlmQ4USdt0/aMgWgS7yQfc0H1FgMAQvBuMidLjZyolB15YV+OUkG1FzZ 1lil8xnqqAEj4m+hJTYvJYlo8jx4TAZ+8Ib4IhNB9mycaH0nxuysHvL6Mc/6s6q15qD1 4FPVwOfNBTCoJ4HM2bbEk+VxJfR4+F4KHlD/Tnq9r3wgXUfG3RN8n0CMIbCpx2a1uZVa UZLg== 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=qQ175NIebX6yUupAijy4xhJCiVhtfT9Z75MHK7wrUL8=; b=gT6TZLI1ljfH60ZuC127rVS34tPuuTs/ZFWg4ozFTLHYbZ8LbkHeS1SqIaRSGx8gBJ RYY7tNk8wXk9DAedtrENN9wq2ILxoImhYEZwLBmup7i5XEqxrTDSrYDmtMrHrT7qNzwc HejA5zYot1kfFPWjBs0/R7vF15qsahGuANBryafTeIkMfH8Vt4TkR4AfaZ2L1pgeuHzp frAkiMErYn5nj3RuDXvOIEe9FxLN8iY6EMSWUlFieLYiEkhtM81d8qz5h0/RIlKRKjsa MTAioYUkfVSKnxok+C1pIlwJoinTpHgwix7ALZ0YxRrQnn1aZs3UQlIY2eoH5QE+Se1U 9pzA== X-Gm-Message-State: AFqh2kpn9wCGEX906dDsb8R71KMQV6yjCd/3kPZ+qGPKSiT1pqacW6qi UQTb3sSQFBAqONUtp2MlPCS7nLdj/9Y1dw== X-Google-Smtp-Source: AMrXdXtcbEERF20SSEjbfwaPuyhOHmjqa0dSrozC+altQkBPrSJGStHzZkUMNNv4myGpFdRtwycFCQ== X-Received: by 2002:a05:6402:f05:b0:49c:d9c3:ca74 with SMTP id i5-20020a0564020f0500b0049cd9c3ca74mr4493086eda.13.1673975492114; Tue, 17 Jan 2023 09:11:32 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:31 -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 v4 07/19] repack: fix leaks on error with "goto cleanup" Date: Tue, 17 Jan 2023 18:11:12 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:13 2023 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: 13104903 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 F2EE7C3DA78 for ; Tue, 17 Jan 2023 17:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234422AbjAQRMF (ORCPT ); Tue, 17 Jan 2023 12:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234200AbjAQRLg (ORCPT ); Tue, 17 Jan 2023 12:11:36 -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 C487333454 for ; Tue, 17 Jan 2023 09:11:34 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id 18so46001525edw.7 for ; Tue, 17 Jan 2023 09:11:34 -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=71wWR4oI+uI7PeBtosyK068X2Y/5k09NgdPyFYwT9tk=; b=NrsxgaC+NtrS9ZaAj85RLdSH/56f77GOSLd28awE/By1weTjSNL/fQ/kr1VL7mN/C+ b0CDj/2RIJjB4OtprwMxR93jiC94LwaPO0ybsEmFDGslqmY7w9NpnT4q4s+JzdflFZok oZgee6hlgagCmF5B4x7gTY1qV5xkbO7x5X4UjM9c0b/g6wauE4uiM6Ii3Ja6OzZNobpS X4+jW4gHDz8PWNIWLJiBGz6ZGMHcnhfb86u4Rht5dHZ8c7nuIX8mUd9T2MBLu23hwDH3 vehWCsz/6a3BQFA+iq4xZ5k7KSLTRjHcfUs+atS9JRr6EJ2RIjdL36Po7yh4UyAC/Dlv y67w== 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=71wWR4oI+uI7PeBtosyK068X2Y/5k09NgdPyFYwT9tk=; b=SH9m7WwHZNrQ5UKOFzkSYFBbT4cSC1DG6WJezso0IBPXPIyXJGm9fpjjXPtqwrVRg8 CrsIR1nd3A2uFH5NqpSjWUwSbOUlHc54VQmZToyYoSfb2nBOK95ecODhJmTUQ2bl1T9N 625CnaMducldcGbMB7ThNq43k6AMp43gncqpbHQXDB4HyHoYyZxZvJx3W6SyE+WEOthb pOAEARVLU/1b9MgnZ+yEWnXv7A7NbsXdllBNtscoMjYoj71TASel9XZle7rJQMlOxmNi zQanNfpmSZhchgO+4yqJJ5xP78xhAge0V/tqelotDjMCt+f4+xBvtzS0jQDtL8ksajcs T+bw== X-Gm-Message-State: AFqh2krSiG6NOIybobn4SLsmWBv9tqibAJ+j9KQsnDx2PfCVMFVst1p/ byLeJUkeSp25fABjB33dcd7rvkC/KKZtAg== X-Google-Smtp-Source: AMrXdXtyWhO1CfyrOajVc4f1J2CWhb9/uXwXbRKm95iOqSxguJtyI06x2JckcWvWTIRS51CUgFdWVw== X-Received: by 2002:a05:6402:1009:b0:479:8313:3008 with SMTP id c9-20020a056402100900b0047983133008mr3403031edu.0.1673975492946; Tue, 17 Jan 2023 09:11:32 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:32 -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 v4 08/19] worktree: fix a trivial leak in prune_worktrees() Date: Tue, 17 Jan 2023 18:11:13 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 + t/t3203-branch-output.sh | 2 ++ 4 files changed, 7 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 ' diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh index d34d77f8934..ba8d929d189 100755 --- a/t/t3203-branch-output.sh +++ b/t/t3203-branch-output.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git branch display tests' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh From patchwork Tue Jan 17 17:11:14 2023 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: 13104904 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 2D246C3DA78 for ; Tue, 17 Jan 2023 17:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjAQRMI (ORCPT ); Tue, 17 Jan 2023 12:12:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234171AbjAQRLg (ORCPT ); Tue, 17 Jan 2023 12:11:36 -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 9B5F73A857 for ; Tue, 17 Jan 2023 09:11:35 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id z11so46042718ede.1 for ; Tue, 17 Jan 2023 09:11:35 -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=1S66g0/FOvoaQegikCviNJQ9JeEQ/H1N+dWenM7mios=; b=ENVlE6bRorXlj5wHdv5s4iw+fb2hXoFuIoldcEWSKgt3m5ka/gdSBDcbz7ODcayl45 UIsU4tlqRFLXge5lscUHbaYI+kc1HYKTf+x1h352JLqBKcYFhXta/U7kGDwGRCbFPKou pHP541pMUB4FSf+QFLwP2FlZq71CnXLIzGDW5Wn3mo6rmLc3bN0ou0wjLo/xIWOBlzVO Kp3qzsbvuTQA3eH+Fpickqx67/Bh9kNb3z+Bixn074KTBwmxep8KqNuAx88X0bKXe4VI kHHwH8qTYgEWwf0XE5na15Ffohby9uvq4WvXdwxgawj/G2hrilIUV63PGYvz6KqJkT4L e0XQ== 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=1S66g0/FOvoaQegikCviNJQ9JeEQ/H1N+dWenM7mios=; b=EU4/XIAlbtW5eyV873aeICWywHgG98wqeQZ2ZVDisW9+O4rw2ss7ZwjL+lXpTnyGNW fVXEOX5Wfe5geUgsgoFexcdhZP3VZBk5tzlINz5HydakHGibwQxoMcyQzp70WIRuS65q OsGzhblJCqNf2m1lvBeVEIL39fZ1sjENYK15MtigZB7GMolU5zLqAED37ci/UG2WcQXc glv5yj6yCy3KSKq2m1BfJ6cfcHQw6b4WzAX0379mrDYwE6qxqjFOIsKzgZ0vmeis3aO6 e/odtbHECtriEQxEnAT+FTXXVCXY7tQ9RQAeuYDlOrkoqHnmTgdKSoA3CVp92fPexNmO dUhw== X-Gm-Message-State: AFqh2kphtxB2b0puKYVt4wM3A3Hcm1Nq3zEpEsRj6l67qfy7Nw+48yJ8 1nGN6OtS63XEzg1b74zcLi2MKBGWihYkHA== X-Google-Smtp-Source: AMrXdXtdRFLfHtU3u6qsL1Cfwf44IngePPi8BaXP8LE4D8sdH5SZolsipi6IXLgbCIRNCZr+e0VeOg== X-Received: by 2002:a05:6402:500d:b0:499:b604:4de6 with SMTP id p13-20020a056402500d00b00499b6044de6mr16561746eda.25.1673975493807; Tue, 17 Jan 2023 09:11:33 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:33 -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 v4 09/19] http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main() Date: Tue, 17 Jan 2023 18:11:14 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:15 2023 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: 13104906 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 7DD59C54E76 for ; Tue, 17 Jan 2023 17:12:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234643AbjAQRMM (ORCPT ); Tue, 17 Jan 2023 12:12:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234256AbjAQRLh (ORCPT ); Tue, 17 Jan 2023 12:11:37 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540C4442EF for ; Tue, 17 Jan 2023 09:11:36 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id ud5so76961502ejc.4 for ; Tue, 17 Jan 2023 09:11:36 -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=i/TBun5atiNc/oQ2kl9/mKAezutuVYs7tQgzxFAmUZ4=; b=npCNXgJe3wpb6E/NSFSWKqm3R74Q4Yk14We1bkaFL3RI1mI7rqj62CsMc8b6ivGvsu stI7EOz8/MFM5DamBPEL75s+YhvOHi255ZoXi0dso8S39m2NpGL8XmPOv1Jcg4gG3Z7g 84qU30/iXJwS6wrZoAA6FLIy59bOvJqGjGkiZgeQFudjXzeTp42ap55dRYitmBN5onsV I6b9EnKShbSPee7DuRAX47PRUqd2F8lA1tJ4Y37G8krF+wFIdnTcb47F7WO6eZOCcc23 XHV6nq0meUm98ooZKHHRB0lUR10GXbKeyFjXrVSAw/JXRZR29gv7PK1w9ohI+sIBKu7S oA4A== 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=i/TBun5atiNc/oQ2kl9/mKAezutuVYs7tQgzxFAmUZ4=; b=q/1Bt3BmFQsqbv39fYBOH9aQIoF0uE9POUlYQtSyodiaxOlHKhDQrwoUbxJxPYCx/2 erbGFSuX+kOailgNKmlKG0gbi5154Tp5E/N4NwO0Ubf8wqk4T54dQobTdxuQewBbQYVV /fkY4Kmg17szmA0+8n7KOveEDCP9PSn8mJeAiw9uVxPSd8jFBoew82FAbzWgbWY1QwxE Lrw54CHueTvngwHsBq0LT2lyE/zKTENtjAEHvaPi0uWutkLENZWmI/mqsb8eAkdc6VEq zR4m6AA4cv07Iw6cGOb8ev53s4x41zC8si/KHUCde3E08/ZznIQ39NmWAUVggcH5+3b5 0ojg== X-Gm-Message-State: AFqh2kpOvlDPIRRM4Foq0WneGn/A3gnI+TGnq8Pt8M2SeLLCd/ZaFLea /a31G1u8TfZPCY/WpP9NLmd0BNj3evluNQ== X-Google-Smtp-Source: AMrXdXszb72R2Zu/eEmYlrMRcrdv3qml3kVcZpLFQFB8AcOgjs/2wqUo7kdr+dqjWXx0zDp7RVfUuQ== X-Received: by 2002:a17:906:9f03:b0:7c1:6e08:4c20 with SMTP id fy3-20020a1709069f0300b007c16e084c20mr3967732ejc.7.1673975494663; Tue, 17 Jan 2023 09:11:34 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:34 -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 v4 10/19] http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}() Date: Tue, 17 Jan 2023 18:11:15 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:16 2023 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: 13104905 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 B407FC677F1 for ; Tue, 17 Jan 2023 17:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234641AbjAQRML (ORCPT ); Tue, 17 Jan 2023 12:12:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbjAQRLg (ORCPT ); Tue, 17 Jan 2023 12:11:36 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C4C442C0 for ; Tue, 17 Jan 2023 09:11:36 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id y19so12433036edc.2 for ; Tue, 17 Jan 2023 09:11:35 -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=J2fJJud2NPAFFQ9AJyYBbG+qE8iKqwaUyGWWhxkOPUM=; b=Dar/Mbk2EZZ5v9Zf0AmpTRY3G/E2nqVcl27SSeeVEDVNxvvxmKU+MsFlOV3IYhG8Wc 3kY2mwkCX/d3P4lUnm7f+ykP9wJ0S7BkY11wmEnQcVq+pirxSRzaGMOA73pFI7qWlSXx Qf1shW6Ycg1TGkcF82QrCzJhC3JSwnGIk2fl5kvZbitBmpldOHJ2QtY9bdgFveOe2650 u9aL2FDwOUy3Z4ooCYgDNOoo29zxRtHR9SLBcJ784z/XkibofaTxO+9XJg3D5T+MZC4t KI9G4uoMu0aYgxSFZNXDETvKwGmSSl3cTvEahP5NMJ44PVBRyjgosYLN9+T1BiT/lR0I YtcA== 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=J2fJJud2NPAFFQ9AJyYBbG+qE8iKqwaUyGWWhxkOPUM=; b=N6lb2wixkEtLJGmpcIrUUSQGgkda646KwtPkm2ToyiCGErIdNDA/jVuQUsEEqMRHTp q9D7+i+9Ibs1GV28ajtkJNvJuRGEcQDLhpUpBehStqK5LwhUDT8tSQlh1zNfBRj4h9Ri lV5GXI8SAtmGieKZ9WC7r2y3sULq27Mz6OuBi+ZHs8z5UOT88FAqXYtRRn8g79A375Rl cDXZNgpKR9muzzLTVt46SzYhvUxh8rNjlaOlzXI9uwqTCXFI8WKVYmE61IQrzFmMU0b/ iQjMozMLv4rRgcSvV8Ne+TUupbnmB2Vevktt/x96F5eXg7KBJhcSPKOqyEgRhqEiUGKv M3mQ== X-Gm-Message-State: AFqh2kpmQYJEBDa28jpHc7p/ycJht7Om65rgkiKxfBLThmX3s0uSuoFD VwNFrq9bl/FMF2WGyJiLGfogKrUPSmYtwg== X-Google-Smtp-Source: AMrXdXunyNfEq5IiJ1/Vs9yk1EW+8yNlJzjXuxy5AYEDP6k96fUYePIXOYq7K537DqDhOXlUjg6L5Q== X-Received: by 2002:a05:6402:209:b0:47e:15ec:155e with SMTP id t9-20020a056402020900b0047e15ec155emr3642779edv.26.1673975495350; Tue, 17 Jan 2023 09:11:35 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:34 -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 v4 11/19] commit-graph: fix a parse_options_concat() leak Date: Tue, 17 Jan 2023 18:11:16 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:17 2023 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: 13104907 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 7BC84C54E76 for ; Tue, 17 Jan 2023 17:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234734AbjAQRMT (ORCPT ); Tue, 17 Jan 2023 12:12:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234394AbjAQRLq (ORCPT ); Tue, 17 Jan 2023 12:11:46 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B0F367D7 for ; Tue, 17 Jan 2023 09:11:37 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id qx13so18544841ejb.13 for ; Tue, 17 Jan 2023 09:11:37 -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=WUT9TATv+YLRC2uUCx2k7tfPpdBzKTTjVU9oWfociQA=; b=dtVp+a90x93FqMDoW2WLPqASaAPXiOSgpHNTCBhpkQnjE/1m26FRSf0UzNdbsUEYW9 1QiJ9O8nT1KXzIGaG213bWGcwQ5NIfwdrJWVCHuUmwUkzPF3+YCG250/Xvrr4S7HJTaJ PTwC7IdC96O5MCjWFKaxnOHtHvgwEl1uW8XLdsNM7pfQdhXB6iRf3dQUv1Rqjlv5d8cG CU9CxG3GmtiB5hl+R/4SbJbsfVrfMmPCz1u8VsOA9PeoVN0FxD4ZztSFCUI85BjMbpxE I2FyyCyX1WvDi1z2CwhQFt/KQJG/M5rdE63LtR3PrHs5nsjHTUIyG6uzlXDMp6mhHT0z aq0Q== 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=WUT9TATv+YLRC2uUCx2k7tfPpdBzKTTjVU9oWfociQA=; b=P4rsf7OnA++k6NbOviBQwaYwLORsYxn8TBf098t5WdIR6KmUowEPuJkrrGLV2QOBru AWT8mvos5XhjiD6HqhzK3fH9GtDvtOKq2TGJvB3erCRi4t1MR8d6qNk3KM2Jismpaayl 2RVriFqdG+xQ51zGiadUgojgxysXEeu1y6L8vQ+getk+N12pJ0xDUsmS6OOOQVEStA2T bxNrf7UqMycoM6C5qxHda8UYb1UMEwmZzTp+Gdyp9O7nyYHQ0OaMETocpcIVrrswUpkU CLJXTXE8nCYhwmEXQeiwnCB4RuHEOcvx0IxfxtGUyPb/Obrzf1n5XRTEhCaoNM+IUZDT TYaQ== X-Gm-Message-State: AFqh2kqJvBlodrmvspssYuvcP1z1JZLe7KlXRsLE8s2Gy9OcmKQK7w48 4y0FeF/BvPCsJgSGmLvgoXlgaKckkizmMQ== X-Google-Smtp-Source: AMrXdXtrpoa1J6Nrr892lMAGOocFDKZ2R9JhPJ9JCHBlolSEFfrltXR2/zx/q0SBEWWpv/VYTnrV1g== X-Received: by 2002:a17:906:e098:b0:870:8beb:9735 with SMTP id gh24-20020a170906e09800b008708beb9735mr3570641ejb.54.1673975496064; Tue, 17 Jan 2023 09:11:36 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:35 -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 v4 12/19] show-branch: free() allocated "head" before return Date: Tue, 17 Jan 2023 18:11:17 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:18 2023 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: 13104909 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 83E82C54E76 for ; Tue, 17 Jan 2023 17:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbjAQRMe (ORCPT ); Tue, 17 Jan 2023 12:12:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbjAQRL4 (ORCPT ); Tue, 17 Jan 2023 12:11: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 B4434442F0 for ; Tue, 17 Jan 2023 09:11:38 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id w14so28690092edi.5 for ; Tue, 17 Jan 2023 09:11:38 -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=TVTn2r0i+8AIzxKvh7W+2HtTrXcgAylSzXmEKCHhhwo=; b=iaz6dPZXe1PzciEKTbR7o9OuDFDhE7b4xujSaXXq9j/ioxYN0cRy+KHvXBGNL7lb94 R0S2v/syNapzJVHKsjMASBWJUmnAQeX/Rx5JijxJNWWJmNi1Isxlv7yDnzF3UIAAVD6r s46JInvyMBkVofnsL1lvaON1s1G1TC+aD+Ae4Bnivz+LNYBkgBmcmSbkUn6GjNNFfn4t Codnf36JjVCqsQxsxaCuUnS9+LGPdTjS3rZg2BdM41Y+GUF65bUpD3Z6pPWJxrYP05nQ UUyFYJxYU+EfRDX4ekcJmhWp7TmdBntiHnzHuRHbCjdqZWWvTq5OGx5Hd6ZeUvRktGSY h1xg== 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=TVTn2r0i+8AIzxKvh7W+2HtTrXcgAylSzXmEKCHhhwo=; b=az+PuKmsCw6oViM/o2smpxdxLPCc17zCWoRP2bxSbKXppNi8WiNvhJs32XfuS/OGZi bTEpI4JFGLq6GQkOhhP4rL/M4X24g1L9JZVAGx8sqxNX8QmJZOkUixEKTZpCuepNsOrE sQTtnTsZHQ7XSWJEwI4gft1WVLjmhV+ogFt+jmqwstyobN1oQKYgP+gIX2/iDTAXADwq I4bSnv5AYfdim1loYJegF/9pF2f+AXM9VNPQkNPgGBmJE2tTOwnaPHhbVPGhYrnjCyhE xRfZIO7BQH0nKrdo9k6nD45rxZJ2csGyy5FIvxB2rJSPVTIb96ltrUASL5c6tCSnpfF7 naMQ== X-Gm-Message-State: AFqh2koEXb2OzVFmWlueWuDvaQIWqzf3c+k19mV/EiaasPf4YTMde6IX qpd5K7jiRQ+iblLTyb8LMWnwYbcM7zGv1w== X-Google-Smtp-Source: AMrXdXuFxbE1Ezrb3sakwE4qIC6NSUi4pvx3jMi7Q5XfVNtWrhR87o08RDUFG77vd+ZBAj4LkG9a3Q== X-Received: by 2002:aa7:d887:0:b0:499:1ed2:6461 with SMTP id u7-20020aa7d887000000b004991ed26461mr3957584edq.17.1673975496824; Tue, 17 Jan 2023 09:11:36 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:36 -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 v4 13/19] builtin/merge.c: use fixed strings, not "strbuf", fix leak Date: Tue, 17 Jan 2023 18:11:18 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:19 2023 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: 13104908 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 1BB3FC54E76 for ; Tue, 17 Jan 2023 17:12:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234253AbjAQRMZ (ORCPT ); Tue, 17 Jan 2023 12:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234508AbjAQRLx (ORCPT ); Tue, 17 Jan 2023 12:11:53 -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 343F2442FC for ; Tue, 17 Jan 2023 09:11:38 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id 18so46001789edw.7 for ; Tue, 17 Jan 2023 09:11:38 -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=2XYzzDZOSUDBBe1ZGCFYhwfsb6htnueNwPuJIfYkT3Q=; b=S600OSi8skaPLrt6TOcHtnbBHhCVcHzHtL7J4MdDyD+cncjDL7bX9IFVY7a7Ov1WzZ zBqS26LLSF8HnfN1qTY3drvVm4CbyN8YmphK/J0MwvjjBLqpmrBJyr5AAmLCkas22SyJ e1zL36oMREz6dDoJQpI/pJvclxcP/FKwCcykT9qRg3sjYbmSc/jotBh12+WaZzWaKUID ErolDr8I0BtkDI+OwMzcE/HVEmfEZEzS2xOSxvIiYCVho0CQtcmqm28+cv7nEfKOoiOz LRv1m6K+V5mGDzFHOunjtGR717yOerc7HKeaSSJTsFpLr73ebTIrwl8wYex/Fbuz6giV DEbA== 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=2XYzzDZOSUDBBe1ZGCFYhwfsb6htnueNwPuJIfYkT3Q=; b=NTUs7U6DxYERUnj5JcDRXzM7uvwy5Lg4XAR474/Hif4sBHeN6dFIdX/doJFdzHaBca yuGpVcjPyJaX/bTfp84HSpQVNlUVE1TcfvKQ7YS9E2T+2/h+1hs/xFYMCW/uN7Ic7YaI BoFZLxKDv5pxByjKe4fCCE4adLlfJAnjK+Zc+Kts7gOk/k/nTw3gCrkRvrNntGjpl/VH 9P/J0Wb3IUsdmrBLG1t9HF6vqSCSnxAzVrGnHT+8PxRRXfhS9Xricm1xtJh74hIwE+pY JaoXZsyW4pzedbzajvhUlPueSyiID4O+UOkDyamcfqvU0VcSXdfvIzKKwRIVNddxX3LT Q4zg== X-Gm-Message-State: AFqh2krtGSpIYw0FbjNMWs4p4t1Q1L8fgv6s27Q2H+Mb7KKVv47EMo+7 T/7fREYqO1lzgwzpO+8fEyYyKLsyYEysTg== X-Google-Smtp-Source: AMrXdXveEh2+32bs/6ULABKvvjAQwWe83+FXr3g7GX1jWPOgCHyNMuI86XPcDynKygfA2zx4GT+dlQ== X-Received: by 2002:a05:6402:298e:b0:496:6a20:6b61 with SMTP id eq14-20020a056402298e00b004966a206b61mr4067136edb.22.1673975497490; Tue, 17 Jan 2023 09:11:37 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:37 -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 v4 14/19] builtin/merge.c: free "&buf" on "Your local changes..." error Date: Tue, 17 Jan 2023 18:11:19 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:20 2023 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: 13104911 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 3338AC6379F for ; Tue, 17 Jan 2023 17:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbjAQRMu (ORCPT ); Tue, 17 Jan 2023 12:12:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234637AbjAQRMK (ORCPT ); Tue, 17 Jan 2023 12:12:10 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527D74521C for ; Tue, 17 Jan 2023 09:11:40 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id vw16so13785482ejc.12 for ; Tue, 17 Jan 2023 09:11:40 -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=cNAdvILvYHVHQZagSiHg7GRtC8IV2ThQrGptssEb6H4=; b=H8ap4IPjuu/EfgBzZGnpUABOc8AGhr8hXPFJzKzj0y361rBS7B734E2sM7Twb6KF2l dgPgQqi/dI3IefwnQI1ZyvhUmo6306x8yAovVMR8xxJjyzEfD0FF9cBh99kgf235LVLr eFFJWhuUjeqOJPhi5O0qfBHkLzWr9/d1oNmta/ThF+EjLn49QqhnXc6RxJOQvonBjbSR dvpngCGX+LyfU4JvF79oviQcvLivClVahbyxciumKoRJdFJjKhazKX6oVYfk72j7vP8Y Fv3RONyZgBUz91IDOLee0t/rlROU9fTDd0lt1qmPMTTSa9DnYft+zCabIiy7JB4d6qnq Wuiw== 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=cNAdvILvYHVHQZagSiHg7GRtC8IV2ThQrGptssEb6H4=; b=1/tW5l9mHl0o8JeBzATn5br0h+z2WVNKv+Ab6dQ2MRiFUX9qnu2V7XV1QGmeBLDj7r lz/XpFSFKXMcJ8tkrRQDF2iI0FkndXes2oec90a1BEBBEeAZXodHwRHNrmC/ItlO/BSW zPNDam5rvY12FvobhEyIo+bBqsfANhM/761pfHZxsZV8+pAaOcbDcwwEFiuowS8/bPSs UbOb7yku4p42HKVtPc7ffw3HG+NdGXrWVAUcsSvRzKNp6wFsgjoFK9PN1Ggh9iyPuzjn zusSo7DYNriMz7Vd3Hn1+HMc/6t6EoRVW/bY10SEQumYvx6mEeFPlgSF+yiUUVvRmlyz KSVQ== X-Gm-Message-State: AFqh2krUjWuWafhKj9XlKo27U/+QEzKcUOLxEsOGH55bl8eYSP9YvDy/ DKm+4dxAynFgBylQdwKdSqsqeec3AzJ+HA== X-Google-Smtp-Source: AMrXdXv7tDPjC78sS5JnanGVcX8sZTHUqox3+NvQ+yh8CU0iyQbk+V0KoDXNU+kPdejcBNiqzuDjZA== X-Received: by 2002:a17:906:4e09:b0:86f:2cc2:7029 with SMTP id z9-20020a1709064e0900b0086f2cc27029mr3808801eju.38.1673975498403; Tue, 17 Jan 2023 09:11:38 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:37 -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 v4 15/19] object-file.c: release the "tag" in check_tag() Date: Tue, 17 Jan 2023 18:11:20 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 80a0cd3b351..b554266aff4 100644 --- a/object-file.c +++ b/object-file.c @@ -2324,6 +2324,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 Tue Jan 17 17:11:21 2023 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: 13104910 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 4EF8AC3DA78 for ; Tue, 17 Jan 2023 17:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234871AbjAQRMm (ORCPT ); Tue, 17 Jan 2023 12:12:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbjAQRMK (ORCPT ); Tue, 17 Jan 2023 12:12:10 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5272545218 for ; Tue, 17 Jan 2023 09:11:40 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id y19so12433326edc.2 for ; Tue, 17 Jan 2023 09:11:39 -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=Q+BUcbwSdm8pyvoCjUjcaG+1v3Vw0KRT8qqUiTgW6/o=; b=BWJ2f+/AK4VnG03qZll1Vj7gbXG2CoFnA+kY+qNY0p4jykN9xortheJ89rN+1sL3e4 jpwXUrkiXt3ziUDk4fV4QeNdnkDUmMY+MhtqNnYddDJ9LTfAA+2p1oris09WpwrncIe8 Myf9N+Sa525mS8DsM03wazA/MSrDgR6R1IXLL+gUokfIaZIBdHGh8heewAIs7aIQAN/O aEBy+byQD4AXb8DKHrw9gi0LahJ3TBuFjMXgO+vwiVlzobB7Mhm1avi8pELo3a0E+i87 WDbt290uxXZa2jKPz3CCQjXcONSDrWMYfLBuP3myqpKnObfyTFiN/tLRTrca2G0r39mW F8iw== 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=Q+BUcbwSdm8pyvoCjUjcaG+1v3Vw0KRT8qqUiTgW6/o=; b=KFny2VrZLhosn+kBGXCIHbJtDMNpksGB0hwEkN4dUDgpZsbM9gX3Apg/4J+VEKESrZ Vca/JvjcqFAqtEuczDayFMpVggLdCaMfBVem9PuYpJu0TrB+F4c1MZJnjY51+KKYrogb 5WIgvnwzDmhQlieJd7O6clxlxVTzDt3pxm8tdd/3YyFPZPIe168DWsHAH16TWFTyyYZA ntUfsCCA9CVpRSkxA2I1cwau/JlYyOkdhJSNjB4EppuZY1H/RZCHmE/kxW/W8lZhQEK7 7H5peXc57B6N85h3eAMwiD/7L2t49PfojUw049kx+Zs1gmgrzG4+oKDaXicYNGrLfCCR kfxw== X-Gm-Message-State: AFqh2kr80S1rtRuHGeSgDB1xBr95ncxpPO2yIYCRUTjn59xq6YMgI4MJ EK4vv6EDw/tWegqwSJ0no5lpVtTq5K+pNw== X-Google-Smtp-Source: AMrXdXt9xxq1eRuAoej//hnuLaAsUC9hf3hZ8imcSoSLWabeWra7ZgzI97hWWoF+aqIvVAuCOLh9Dg== X-Received: by 2002:a05:6402:40a:b0:499:1ed2:6456 with SMTP id q10-20020a056402040a00b004991ed26456mr3846038edv.22.1673975499310; Tue, 17 Jan 2023 09:11:39 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:38 -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 v4 16/19] grep.c: refactor free_grep_patterns() Date: Tue, 17 Jan 2023 18:11:21 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:22 2023 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: 13104912 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 69091C54E76 for ; Tue, 17 Jan 2023 17:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234608AbjAQRNC (ORCPT ); Tue, 17 Jan 2023 12:13:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234711AbjAQRMT (ORCPT ); Tue, 17 Jan 2023 12:12:19 -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 C037045238 for ; Tue, 17 Jan 2023 09:11:41 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id y19so12433379edc.2 for ; Tue, 17 Jan 2023 09:11:41 -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=z/mRFhO0OP7MX0zd7H897jix2OcNvcOLPx1m+KhKGN0=; b=bMv9gDhTjGD5mP5Vrdr1mug/2ST/Kgp+81b5nmUXUNRwTGs9Pd7JqCDBR6AxAmaFul RbdJ2eP5BBLDkEwOoUxhnJ2eLKcrKQra5fV0mfyHjK60YkkxfjJ/ZTFoSWHMmQ7SjZ8u 8I++gWsCBqYgv5q10wh/BweGDYbTL0GLo3XnyZG8JKLodU8kUvaKsEG/wmMy1FYL/WAH 3Fu6tHBBWGZdX7HZ+qVW8aJ2cVfKI2wWH1enDmTDUc3AeffcpXSBudh2pJLwgb0w+y5l umMvREApiKTAHIvtahTy4+KH/0QpCvU5go9/iER4jQXc3HkUGrW2h8v63alfxtm67Roo SWsw== 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=z/mRFhO0OP7MX0zd7H897jix2OcNvcOLPx1m+KhKGN0=; b=Y4wVeUizzli8VkOaKQkq3S6tCE3X5KiRWHO8EgGiBRseYvfpqszuq8bx2I4ptIUeVD A1At6+IWaihyvAYf2+7/uOzu1BKYpOdub/u/ZSo2Om+E7dT8CP6XZtOQDD9shrzNYj7U AB/L+GX5KlYkJq67MSz+i8n79Lwfwnh5DjszPofSVpp/QFyFN5exyJix/EHbhknohGFz myTeH4WNEAEy8ztKV+whTOTxAlB+6oyh9fiJDD+3Urz/i9qWRmCeUA+9GvSTL+vwksx4 ITmVJx/vGl5z3ytbVu2PwitNDEsMOraXGF8Cm24wloyrYZt4kfpV+e0In+tE3ekWL4qg IHvg== X-Gm-Message-State: AFqh2kr2C7PxhTuyAiJSqkfUhHKPvFEkTa4bxg3PB9ilZ3i8CvnURR5P E9f1BPzJRbmEwflZXADvx1icbLW+QTwPag== X-Google-Smtp-Source: AMrXdXvvxfgSrg6j+WcawFlVxB5aaPUiAFJvTyAgLXxTJnSeqfIJFf52ujb5qMj+ATARP+OKdScwrw== X-Received: by 2002:a05:6402:1f11:b0:496:9d0f:3081 with SMTP id b17-20020a0564021f1100b004969d0f3081mr4139578edb.3.1673975500077; Tue, 17 Jan 2023 09:11:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11:39 -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 v4 17/19] grep API: plug memory leaks by freeing "header_list" Date: Tue, 17 Jan 2023 18:11:22 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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 Tue Jan 17 17:11:23 2023 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: 13104914 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 91E9EC3DA78 for ; Tue, 17 Jan 2023 17:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234525AbjAQRN3 (ORCPT ); Tue, 17 Jan 2023 12:13:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjAQRM0 (ORCPT ); Tue, 17 Jan 2023 12:12:26 -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 9978B46705 for ; Tue, 17 Jan 2023 09:11:42 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id v6so45953674edd.6 for ; Tue, 17 Jan 2023 09:11: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=7kTWzCHL6Dj42pkbke7fDrfNF5o2r53qWt9KXITmkXc=; b=V0IqMeSpQGwEbm6Qnze9N3+THA/HvYu85/nJ3PvYwhpQeqGAo85FYWl4++boAQt7Kj dhOu3xoIfkk4cxxq7LEy3PPO1W99GGaZMzOCxxCP1xVBV1hNLIi0SO7iU/5dHXumVTF6 mnKvQEmgLqXh1FMLYwgpYzdaO8qCvdZ2rAFeaTed3AwYzOqCsemFkvgCHn2NnWswwpWH eZTYIzYNraLn9ks+g+3FtWUqvQpUA0k0iKNp1QCH0UjwqLewf5Ux3lk5pISarl+twv6U XuKu/FaSK3tp9EWUxiRdxMs8WmNaXE57sbRP3mwLI0LnAGS3lBMDRWnIaEufcgfPy5CA NNvA== 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=7kTWzCHL6Dj42pkbke7fDrfNF5o2r53qWt9KXITmkXc=; b=UOvSfxyW10upMYin3F55yhHxgVg0t8hiGcdEqcpS60e7Mh9zDXD1UUbs/+g3wiBD+0 N6gF9IZij4ec/8bwgzcJOzMkpwuuD3zMRl+kWeVRWd/WeU9rN9Gguhv+/kHNDz2TP1Oy IEwpA2ZG6MgfhjsANwbwwxnbE6oMEdcwsiYjR4kMy/vTc9G0pK++1+l4axvaudcU8X7+ 61cgtqwnSOfGaA/84JVT0l0SbG2MCG4/dFTJD9v4rA7vVqxEHZZeq0KVe1wT42YWeO4T l777vSDwRYCRk1G2gjnhUoedQq1phUSECd2tufAWoCMp45nGcWVHmgq5gwlU6qN1HhfO 8j1A== X-Gm-Message-State: AFqh2krRVEgHXsbx8LaFhsMZUjMjmdrzwZyeALPRKMwwsPBwPtecHvfd GSoGYP+ndn4CLWs1sKdBakqParQCteDrmA== X-Google-Smtp-Source: AMrXdXta6pt4GN8zCIDGheVQ3LI/1HvoaJ/8mrYeA2Xs9zo5bi05rbtJxbn9zYsau6tNOh0ijjlF9A== X-Received: by 2002:aa7:d7d5:0:b0:498:dec8:f41e with SMTP id e21-20020aa7d7d5000000b00498dec8f41emr3568892eds.3.1673975500812; Tue, 17 Jan 2023 09:11:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11: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 v4 18/19] receive-pack: free() the "ref_name" in "struct command" Date: Tue, 17 Jan 2023 18:11:23 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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/t5560-http-backend-noserver.sh | 1 + t/t5561-http-backend.sh | 1 + t/t5562-http-backend-content-length.sh | 2 ++ t/t5705-session-id-in-capabilities.sh | 1 + 10 files changed, 21 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/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index d30cf4f5b83..f75068de648 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -4,6 +4,7 @@ test_description='test git-http-backend-noserver' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY" diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index 9c57d843152..e1d3b8caed0 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -4,6 +4,7 @@ test_description='test git-http-backend' 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-httpd.sh diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index b68ec22d3fd..7ee9858a78b 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test git-http-backend respects CONTENT_LENGTH' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_lazy_prereq GZIP 'gzip --version' 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 Tue Jan 17 17:11:24 2023 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: 13104913 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 1C10CC6379F for ; Tue, 17 Jan 2023 17:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234902AbjAQRNK (ORCPT ); Tue, 17 Jan 2023 12:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234508AbjAQRMZ (ORCPT ); Tue, 17 Jan 2023 12:12:25 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D35746701 for ; Tue, 17 Jan 2023 09:11:42 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id s21so1795493edi.12 for ; Tue, 17 Jan 2023 09:11: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=UQVKx0iy6w2tlH8jJSWhs9XAxMlzpSUXsOXqhZO1U4o=; b=HfvQNnGpHJCRxfDfsiSNHKRUddPcfN5xAz5YFwCJ/eec17+02LhvefNypgEIpFbjZi 6UwAwSVyDdJyZx+af2gcbr+ZdOXe9sarzyim9RIGUIPRVAxIEDtlNQR+XkwOyt1IxDol iKMKDeFU68mL6e0tbEIv3VnPES6GtEeoDucU28Mdu0DBoNffvUKP7tOyxv/rXHj28LaO 07dmmm2uIOJ2BQeNKdnmnQ476DiGHx8UbaHTkE8LRsJFHXKXHKSOVXfS3CvW9bq8WItN OS+ri0zpP0yf6otjuyBixpWoiPVNgGmDejmRV0tAD7gZjx2EUqTccs5o1wI3Mx3APXGz eynw== 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=UQVKx0iy6w2tlH8jJSWhs9XAxMlzpSUXsOXqhZO1U4o=; b=k1LNwsByCzAJ+lIaUmgPHbXNgBabutm9T+Kjc5y7HoOyNzB12lhaz4pssWZeCn/tNL REvam2Ogc37SI+AiSm2i8TVOSSqqY5oBwFJnucy0DDyqAJ2kHL+L4zH0Os3NIF0AUvi0 MPmh33iiwvz93QJS3nZt0H1P6+4lLT6l+eVdHaWHmCG7T0S2RckI8ApeXtwKlV8nDCdF +LI75yaJB4tuOndys/z9OMdX9DKMZPe84aJnLM3e6gSKtn8YAdqhgm49Q8F8mmipTZab VuWBcTKkSiMWgO58XFpr8JxlvrZRcWx3wmq9Li+wWKsnTasMTQ00LMvjPqItfvRYmgzv CKig== X-Gm-Message-State: AFqh2koP1NoeKNBcgN8MetpdNwiPVmP9likjE2OsIZMCXfZM0jAeil/o D3EKvaH+W0mfpwAvmTSxGDBCMfzl4SKdPQ== X-Google-Smtp-Source: AMrXdXvqhz6B8KxAHs7Z56ZmuD/5DGxsk2JQwEFav9PSZyYEa/yspLHmHmgkBY5eo9oUXSyiKt/vmA== X-Received: by 2002:a05:6402:3220:b0:49e:1d59:794f with SMTP id g32-20020a056402322000b0049e1d59794fmr7445380eda.22.1673975501533; Tue, 17 Jan 2023 09:11:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m2-20020a509302000000b0046892e493dcsm13191268eda.26.2023.01.17.09.11.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 09:11: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 v4 19/19] push: free_refs() the "local_refs" in set_refspecs() Date: Tue, 17 Jan 2023 18:11:24 +0100 Message-Id: X-Mailer: git-send-email 2.39.0.1225.g30a3d88132d 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/t2402-worktree-list.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 ++ 14 files changed, 21 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/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index 79e0fce2d90..9ad9be0c208 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -5,6 +5,7 @@ test_description='test git worktree list' 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 From patchwork Wed Jan 18 07:00:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13105775 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 5C992C32793 for ; Wed, 18 Jan 2023 07:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbjARHkb (ORCPT ); Wed, 18 Jan 2023 02:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjARHi3 (ORCPT ); Wed, 18 Jan 2023 02:38:29 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB74E32E74 for ; Tue, 17 Jan 2023 23:00:34 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id i1so10390947pfk.3 for ; Tue, 17 Jan 2023 23:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=ZZFcw1A7c0NxWlGZ2/AG3Folnq0FXlK47KTLoBfSkQs=; b=Ygf7Jlb8oHKfXOvNk8DPxUfI1U8Txqpp/1MFBwHndyJXTakKgoxFVX4F2E3ZaGll6W zslSs36moZImbNTeJTYewr4MXAC9Y8+YXAAIWbaZDafwPSrIrvtFq8d5BdOS8lbPtLC2 Q5FQQkR9LHaJe6onfLq6vf0FYO7H+sXHyHA8GeQYqb8afpBnQpxN09y+TNlK/KXDscFX mRLKrTB8Xgs8VXPodG3sD5IKoB6KitR8otgWGjMRJBeKyLE8aLIoJa81mONb4WCW44O4 xDqaSoJRbJBRNwx/xu0tZM4dg2qsH/OOwNF8Z4PZG5WfPJ+QLHjL8AnAwwWAiO7xKyWN aeDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:sender:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=ZZFcw1A7c0NxWlGZ2/AG3Folnq0FXlK47KTLoBfSkQs=; b=vjc0V1UYhtT9zwft8ruT37TqoHEjQnY5WXMHnXGlXYtITK3ZidoSnJXZrC1o6OSKMR XV6Ufp7aMY1xCVoWrUvkP3e4ZuGf0SaHpnJ4i+NfhV/uKSKBHi7/jT1IhPY/9ywO2lZ0 KRYIxsGqXQq7E5qsHnVGxgeOADtHvadclNIursUVDMPA5Xx/qzmNOSmm+vhzmb2/2F0E 1homZN9fukUXlnNAR5nc+KMaOBuYXgpFSGrGqgSvMeQdThVVXuFdyHszLrL7KKKkg1NE TSSFyTCzK1J6tb09jpyQp0MAaUKMZ4zlzJ8WG6rwjdlpEiJqGa46027Wf6YzLF3uPkvS /J8Q== X-Gm-Message-State: AFqh2koCdEzhnXRKh+bAre4uULY7ntAcmQhdE3OMT9c8Pn3Dkj2fcvcT qtet4NOVLCwBntrb0lG6euU= X-Google-Smtp-Source: AMrXdXuXLujZUKRy8gXyc6adrjW+sBC10nlgBzW5d9HS7mMOh4hgwmAOwK1gp63rA+YpRJodZBbwsA== X-Received: by 2002:a05:6a00:4088:b0:58d:9ad6:6ae7 with SMTP id bw8-20020a056a00408800b0058d9ad66ae7mr7062120pfb.19.1674025232398; Tue, 17 Jan 2023 23:00:32 -0800 (PST) Received: from localhost (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id p12-20020aa79e8c000000b0058bc7e47a58sm7158695pfq.30.2023.01.17.23.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:00:32 -0800 (PST) Sender: Junio C Hamano From: Junio C Hamano To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, =?utf-8?b?UmVuw6k=?= Scharfe , Eric Sunshine Subject: [PATCH v4 20/19] branch: the ref_filter is not cleaned References: Date: Tue, 17 Jan 2023 23:00:31 -0800 In-Reply-To: (Junio C. Hamano's message of "Tue, 17 Jan 2023 22:28:28 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Recently, a test that uses "branch --point-at" was marked (incorrectly) as passing the leak tests, but it was premature. As there is no API support to release the resource held by the ref_filter structure when we are done, let's mark the singleton instance that does not grow unbounded as such with UNLEAK() to squelch pointless leak checker errors. Signed-off-by: Junio C Hamano --- builtin/branch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/branch.c b/builtin/branch.c index f63fd45edb..4fe7757670 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -742,6 +742,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (filter.abbrev == -1) filter.abbrev = DEFAULT_ABBREV; filter.ignore_case = icase; + UNLEAK(filter); finalize_colopts(&colopts, -1); if (filter.verbose) {