From patchwork Wed Jan 18 12:08: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: 13106328 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 2D2BFC38159 for ; Wed, 18 Jan 2023 12:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjARMqk (ORCPT ); Wed, 18 Jan 2023 07:46:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbjARMpa (ORCPT ); Wed, 18 Jan 2023 07:45:30 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C954B2BF06 for ; Wed, 18 Jan 2023 04:08:36 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id hw16so70863732ejc.10 for ; Wed, 18 Jan 2023 04:08: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=79enDUK9Un78iCLGnZFE0UeOMxA4gUH483+8+cNxVqk=; b=Tbk+16/HJbcFB9RQEbpYut523z+0zUPeYxj4WyZKCi324RSDGqg20UdLvj1R9QX/lX na1zriIy/E5rP75mL9FGlui7Ukj+GmDv+QsHeE6VpcVPnvinlf9+ObzkYn2LDZcChRgH GbVnQJRXr304yTOlRRoWc9tIYWQafUyrTQQADieEkFsrtKqgA2HTIyDiBaCdSCNb53rm TxtZS9LktxkiRwXah+JGrgqnPh4Q3C4wOR8D/YRIaHHA8nehzo50QDBVBX+U6cXfnbD3 1puwUTAAcWmVmvSd6DClGQ+9qE/z4NGmdnn9IqiCWG6B8I+66j8QWV4IMPcT9nZD2GDo 9XjQ== 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=CLka7tTFhARun4zQ9bua3k8hfTZjaZSZeDvLAANveK2I7aIjq+8VrAWbnh+m86FbP1 gY4Hsyo4KQDV+RCg8mIzLqlHogZO13l/sWYWwcWUA8J5ppCNfMWU90vdLRFPFLMiOJEL 4CisV/QiV++L+ZxuiyHWOCfWkRju4VGE7M8RO07+0+hej7UxbNg8E/vI7d3+uEXqkDQl B81iuXgYRWNW9lBBFKt7A8+WjQSmtmg+m9VbrYaLGz+IP8cwedfh7kXKhcekn5YqSdTX ud0x0xvTF3khEPjxH9Fx77zndfK/dkmPrEv0qMQ6iwLV9ZQNJ3R8z2xePASZG4dw1dze 1b5Q== X-Gm-Message-State: AFqh2koQNG7nsVe8mifJ+w0xAqDqwlh/Qdqh6Y6ofS736SLnkzjYscz/ 0VL9oBk7eAiyBGs22jSu0xDieQU80QuX5g== X-Google-Smtp-Source: AMrXdXtuEMIvzg3GmF0XZONKhlL9olicOcjJzQyEqeHf9Yii/NT0XyqAoSqUWdRjWFwoupFkM01NUQ== X-Received: by 2002:a17:906:6454:b0:7c1:277:cb00 with SMTP id l20-20020a170906645400b007c10277cb00mr6567128ejn.23.1674043715142; Wed, 18 Jan 2023 04:08:35 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 01/19] tests: mark tests as passing with SANITIZE=leak Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106327 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 9B2F9C32793 for ; Wed, 18 Jan 2023 12:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbjARMqh (ORCPT ); Wed, 18 Jan 2023 07:46:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230449AbjARMpa (ORCPT ); Wed, 18 Jan 2023 07:45:30 -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 C97482BF19 for ; Wed, 18 Jan 2023 04:08:37 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w14so32007867edi.5 for ; Wed, 18 Jan 2023 04:08: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=5HgRUV8vc+1/isXemg17KC16Xl/Kcpdk3WdYy0RAdlM=; b=RicZseMnmYKhAG2XqpPgK6ILZ1eICwrLil3oPlol8TfzSHb3V2LIUxPDz+sh+j9hv6 kg21NuVeyf4Wf8xYq+n351o2ZeGhaNg9BdPvLgvcNwwOVUxjRhQsjWkgggPwtnxupY6g 2ST20dkuaYpfIAtiNI2+LVbUBtkBre6i+PLwCy/hVphw0BrGLRdlImIXg/Xn6e65O93n Uo42gnJj0AV0ZG4hkjhx7QGR30SF8XoEnfRz5oOm+iFazQMZomGTDKQL/nVud9JF00SX uNP0Ij5j4ykRtvzEnomiVfrQsapOFWvlIOYc2Bg9CLYKC2UzQ3V5ufqyz8QVuqfCBli4 JAYA== 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=PCn/1tM56fXZhj5u/9YRTLBMosaQBsbMKvRo+8Hxw7c3ptcLEBdoHBEFUMvahPUqbH a3VBireZ+eCUj73vIeGTS6kuX3tMbuCcNeH0s3ajPQ5DDTw1XRFrI4L++hr/z3Ly9BEe p8j+e4O1eWbSzi7x9XdQ/1gKimb65IlFDX5voRKSEFZXjEEc6Xfpvq4D39LTBhHlkgWo jix7ni8QBTp75APugnh+Csl2jzNQnsI4tyIyo8bPZXQX4PuaC9W3P1rxJ5yOLU2S8DUH AACMzE239/QACFkhNbc0wOYA2oyToXfNUKS4a9vExkXhxqBQXF+1WKrhoW34K1Tdikyh 1cmQ== X-Gm-Message-State: AFqh2krOZUL+s8y5DYAVjh/ERwkQGkBaIVTCY3B6FSBD4aK/QPIuZ+pc bKzPakrSAX9HRLEb3HEVN6MD3hideKHEdg== X-Google-Smtp-Source: AMrXdXvA93z17jeb+cTWUQ3c2gU+ZlSXg3p4wFMq4PvCpieRHP1pnXfnZdIFpbxH0UPjfNNEYnfpJA== X-Received: by 2002:aa7:cacd:0:b0:49e:20f9:4ade with SMTP id l13-20020aa7cacd000000b0049e20f94ademr6606642edt.10.1674043716020; Wed, 18 Jan 2023 04:08:36 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 02/19] bundle.c: don't leak the "args" in the "struct child_process" Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106331 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 99D17C32793 for ; Wed, 18 Jan 2023 12:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbjARMqt (ORCPT ); Wed, 18 Jan 2023 07:46:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjARMqC (ORCPT ); Wed, 18 Jan 2023 07:46:02 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 476BB241E1 for ; Wed, 18 Jan 2023 04:08:38 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id bk15so25205638ejb.9 for ; Wed, 18 Jan 2023 04:08: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=EaSBqhwqTjB2hNqh3m5vH/RC9JqHAeewvEHTqaNglZE=; b=GHKwiHGkjxoYk0JUARFYmOFUAnqlNpeH27xbITYohPkZQeFHKpsJXSe8vPHoBM66Lg T7wjDZxn5yZ1SltKHOvehKWalXFju7HKauUJlojaooXZBv818xQuQyQ7yitCKJKYOzpt LKg/oE6NTxn8B0IZM4CAgrRLcyzsUzeysJx5DpnCXrxbTLY7kYhZCX/7xTdaxjj3qP6e gtAV9hGoOZNyMgxk1o93LHBvIV+qj6jZRuJvL8wDKy3WB3cH2k/Ye5cVQSGTNt/CF+Dz 31gAXfBuZjeGHzJfQTvclPKAt+/GPPcmTWx28aQG6fhx+fMgBser5lNwtJV/RdyKg3g/ UXDQ== 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=gIooOITtNXtksteGzi2QQd93YebTLoaEPKpJXKjX8wMM4j3LY2Ugo69j2oZsoPBXqK e/mlJlr5xCtMO2EXGcf3N+hTn2+gq7aSocKgI+pHVo0pc/SPQ+GrJJ9a1aNovi7VSuCP sp2cLSt8heS6b8DwmPqel2h9LNRj1p9f5+FMlJ+qvDQAKwwfpa0ixMXPgkUrJNjSq/GF dkyXzTiCLMZCqrAeFAbLDTH5nI9S+QjxqTU7wUD8DLI79eL5I0GmXm0AjW4rteewklQs 4Ig9K11ydY8Ug/7boVEixIlgJe56WNhIsbKOD4LghY0O8Af05s1yB6ZyrQT3RWvfcWV2 KZOQ== X-Gm-Message-State: AFqh2ko3s5DoErIJNiz16SAmti6xrqZhDJN1d4cQ5//KH59QnLJH6FcX shVWkcg3zo0mPvvl2xJXu/BB1cLmCQZE1w== X-Google-Smtp-Source: AMrXdXt8XNZ3rOBV0TnPz75QezWqQbvu6yNUYh9n8Djvu9pkeUlbZayyCO68LZ17Du/yJ/XDefWEbA== X-Received: by 2002:a17:906:244b:b0:7be:fb2c:c112 with SMTP id a11-20020a170906244b00b007befb2cc112mr6425846ejb.66.1674043716899; Wed, 18 Jan 2023 04:08:36 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 03/19] commit-graph: use free_commit_graph() instead of UNLEAK() Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106332 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 25C14C38147 for ; Wed, 18 Jan 2023 12:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbjARMqz (ORCPT ); Wed, 18 Jan 2023 07:46:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbjARMqD (ORCPT ); Wed, 18 Jan 2023 07:46:03 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1A5D23656 for ; Wed, 18 Jan 2023 04:08:39 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ss4so75424813ejb.11 for ; Wed, 18 Jan 2023 04:08: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=QRTnwPrbrV7ma7a3OZWCZwFiOWUu4067NVK87XmGZ6E=; b=oCPiRRM4KHkfVW+az5rBB+JMSBUuM/HlHlJuFAPyce6Pqy2xkBLAUsZTGS4kjp34zn EVUBkg0z/ZVgFnwTizkxWWjMtH6VbvC6vhfWlwzaiE2VtKNrB4CwV9Dh/HIrW9zmhZaV yPsAd/El1XEedMXJJ6kQ58hc+EJwAIyTWrbsElT5WkbHxPcNpJnpehWjKqo0YN8J6lIL 28V2yqI5kpg4uQ9gbCH76/AeX/Pj0avrAqJLe5hpHtYKW0iMbDTJkq4BEcL24Vu/9qWj Wd0OzpmHKfuHNs/W+bealvLqcX38jnHqJHXJ4R/iw+T6/2c9xlLyQR6EqGYG4vPzn+xg 2+6g== 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=GnjG5EO+JesELdMOuQ/WutLg5F8CyWDE3LEWLcJD68OceuIC1qUhgYGFppxDrCd+r5 jBRJqAlPwklxs1Bcq33iQSpEbnCSkg+GVX3HMCt5OJ9UCIkF0PfPeLYNJb9CaqM+FyZ1 21kCfdzFyTcdBkhqX+0lEpTkzdH4b6MxVJIyE/YDDdfWF2OxjvjEaZmXm+xHcaUQCr1W 3mi1+Fmg7wCsk1gn8QqLYZZ5Zm2blb1PuVy5Q+RHSKOuMUW89QGOn+2OpmVRSQOm3Wz6 hEqZujFqvCjHqPLuYJTiBjhxoYUs26p4lB4tiD61Bw0ZMfmqseLB4Vm17pMl0Ida60Sp kgXg== X-Gm-Message-State: AFqh2krzwsuuxql18aPfFzvhp7NuSG73Svtg1o6lAGufAxW5vk7v+WPA E7Jz8OoRdGWcZZI9YyWGtD2S+RZQtP/eWA== X-Google-Smtp-Source: AMrXdXsVgl0mFw//S1zBmkbGkId/d1qHG5umxRpYOmxlgDKEpD5XYDTlvvJKGEDtUfoTISX6wmxytQ== X-Received: by 2002:a17:907:a506:b0:873:901:4f23 with SMTP id vr6-20020a170907a50600b0087309014f23mr6824380ejc.24.1674043717766; Wed, 18 Jan 2023 04:08:37 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 04/19] clone: use free() instead of UNLEAK() Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106333 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 13039C38147 for ; Wed, 18 Jan 2023 12:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjARMrC (ORCPT ); Wed, 18 Jan 2023 07:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjARMqE (ORCPT ); Wed, 18 Jan 2023 07:46:04 -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 BCF16367D4 for ; Wed, 18 Jan 2023 04:08:40 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id 18so49318258edw.7 for ; Wed, 18 Jan 2023 04:08: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=cG+7ZZwi7C15rKfBHpcosgJoEHQ/85pRKJLqCcfbtc0=; b=JjkfexJIedBl8lUYcD78GYuHuCnx8ZiltMyD9bgSEfpXLdBr9HOoZ/7KTbX349JpaJ vIbzSgbpmgkGfQ60R/81U6dspup6Bfss376JHIPqKvgchxdMOzKWKGQ5j52E4MGG7sq+ wH6JYxwkOEwe0TDr3cfy/I0H1Cwkl6usv6etF2mFqvR8W2W3Lxr+UpCRRHnOSFas2Taf ktuR9ev20A+lzHAdOao9DVOryAhHAFA/dnjJHEqfxpXabLxo1lJaDx2gYoLAaJD22wjB hYCE0G3H5pEA4tNamXzA0XKfcDCLKtkR95aosM6R6ivQdh7dm0bhBycgzWibj4w/Jeae wwPQ== 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=QlQ2tJNCLQ7v+M2sIX5EuwfxWIYRKP/sbr2pTArfIBuSMvkOKZXLFRvMGshHjQhvfq q5InSt5DLKbRYjPGki/x1U3fXpTsSDoex/xa/q3brfSKcVJpN6vZwHQQw0PH8Nvep2ZT SVZi0cCwtnekhO4cI5Ezjk+DztaGT/ZCkPyejX1z7DIRWkpJ9vhySmDS3HgrgmakSOW2 N7lDVwCx98ThyXGwoUbpBYCRyDy1SRfp+NpRqrRulEnc2sTeb+sLmEoL4FCRmRiw9896 ZA2eHga2Ty9mJ2ewNOoLU8ZHeVQWSuOvIGIaaGaczqPvQcOQeaJ78WcX5wkKF39NbbAV N2Sw== X-Gm-Message-State: AFqh2koZ15N+QBPaMxtiN+YCPL8e0MR+H26cT19LRG7RQXw0V25IQ9KG U13RWUXk7E1GfUzN8hC+eAsvqWm4uzgVjg== X-Google-Smtp-Source: AMrXdXvtS7zVjmfQMd/Ou3F73abuIIvO0KDem2bJgy4RWDZiTO1yuyLts3asu4++F1amjFvpOop9uA== X-Received: by 2002:aa7:cd89:0:b0:49d:14cf:5f4a with SMTP id x9-20020aa7cd89000000b0049d14cf5f4amr6857728edv.39.1674043718712; Wed, 18 Jan 2023 04:08:38 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 05/19] various: add missing clear_pathspec(), fix leaks Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106330 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 222A1C32793 for ; Wed, 18 Jan 2023 12:46:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbjARMqp (ORCPT ); Wed, 18 Jan 2023 07:46:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbjARMqA (ORCPT ); Wed, 18 Jan 2023 07:46:00 -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 BD24637B7F for ; Wed, 18 Jan 2023 04:08:41 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id mp20so36115907ejc.7 for ; Wed, 18 Jan 2023 04:08: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=JJsc2mByCTaVzvS4IrvPa5rvQz9EYF3b31Yl3yAfz8k=; b=MUCOjqvwsgYxdhrutFq4+jmA7TLR9L5p9DF/EwpHp+c0oKZyphXDlkvicH0jUfpmed 6pR28aaJOWxpRNQtAWMaUU3+HbqV9dwIwC3KewWGxqaObdZwwawjWG2wZt4yDSHyAB0C fYEhj6tB57Z1AhALdW2jqgNYP9UD8B4iqY9hfB+s32j8gbFcIs/sVeOe2vtCvc4xmd32 cldXuTgn0rI/siF1KtJ6xcRy2TI99Y+syxxiJhzujVhu96ZdiOP9BYUoAXv2TYkiMttm cobMma7+L43SnOl5qLcQZTBeY3PWXp5zF2uOo7l8bkzEfgRLDA4XPat3v0fhfcoDfqi7 uMcA== 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=3qvFhPiV97F7qsY1+FUbJ48cytKlmC3QsvYNKv2uODtX9KHXLNtC6u3PmNhSHkZeQO O6N/f2bUHtEMX5CRWbdd82IDnnIEKJkbSjBvQFdH8F1VlbkFbES4xiA4YDjQL9Xl/YwG wuCiHdbyWOYxHSy8ed2rKieGulxjtkviyRAr68cISiq77jAZi5Np2sWw2F3urTql0Zo+ qSVZ83m8UUBwx8wNCU14+1BoKrDcuVf9SRl6ladUUgJ5jVzwblCPgvqa/BNZoyJS1alq zWJZmh0l8isLX3XOA0tjmI4xj9FdbfDxMV8A/5no88r7tTgzBhRCU+dESoMTypWqxKJx dQaw== X-Gm-Message-State: AFqh2kob3UN1+ik5yhXd1uJ7ctX7GqSrReOUVfixeL1Tqh2lOoO8/wKy D9N3PfUNjGDB5vPubiLJrilwzNiO60XVag== X-Google-Smtp-Source: AMrXdXtExrHq7/u6kfeKbnsp7d067HJ29vL5r0uaCoQyrofYUVTPeK0Z3CTILjp9s+Jc+GkENqmxMQ== X-Received: by 2002:a17:906:4f07:b0:864:223:40b with SMTP id t7-20020a1709064f0700b008640223040bmr7245184eju.33.1674043719484; Wed, 18 Jan 2023 04:08:39 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 06/19] name-rev: don't xstrdup() an already dup'd string Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106329 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 B0231C32793 for ; Wed, 18 Jan 2023 12:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbjARMql (ORCPT ); Wed, 18 Jan 2023 07:46:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjARMpu (ORCPT ); Wed, 18 Jan 2023 07:45:50 -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 BEAB58BABE for ; Wed, 18 Jan 2023 04:08:42 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w14so32008135edi.5 for ; Wed, 18 Jan 2023 04:08: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=qQ175NIebX6yUupAijy4xhJCiVhtfT9Z75MHK7wrUL8=; b=UdccGcPuO6OYar+xw1Xqgc8IN9b0yYKM5XScn/UUVh9vaUme4Co0qPpqfvC+L9VViv 2xA8ZYPmsbPjXmA5Wh1CcqGArEDISeNXxis+4v9RRqM3CseuSWyuGoYpdh1t93pj1UYK 92CymKYWHSaUZpSN7DnNdmeW6X8zJMmqciZ0GwxWq1r7nG9gE/GWP2uoPzTHEgyAv5zy 1QRMHT1bHPqwmrxX8QRrkA4ZkNXPUVVCOHtKoPwl0+7OnyUuLCdLjFI1HRW5rOZQ1jxG 9XNjB3VyxQ0mIzzp88YC/RvUbbL8wfx9KB+Nk0+tZBTQyT1FNZVzTYHjSr9NODIonVwR FiHQ== 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=MH8hxkC5hmBM1RWEh2oGhct2BAT5nRDZ755/bKHoA0dPa//J+j2BsG3vXlO3Y5h/aU gKBnXbzob4C4yta3ug0SUalCeoZ7vtF2vfDIWH9R0m6/cUrVXmi6AkY/nvGIKQ4zpqOi dzYewxEIry5N6A86Ow6rRUHmfpSbKp+KHIGqY0TAyv4UB9WgzINs+BGVkCQpLLpIC5cY OC1S4EHsCmOo09lAUhy/YhRovYeBw2N7+Ouk+5xkTUGvdMW/4owRIbn8HviJkx+kvOZI CJJnfMHxYwJOB23Y1zMVjsAJjz8a75/+36fpf7X5ZIPdXIX10J50uJcePA4iVxqk//wW D4BA== X-Gm-Message-State: AFqh2koMoMHYZnHMXAx23dq1dOWJmMcYgnIrp3PUXqCInKL8fK7UXiyt zzmHFlZhfgRzGKDCmqIOxZhbcsTAyDSgHA== X-Google-Smtp-Source: AMrXdXstgQqq/Le9EbyAtoMiMEdeHGac97USClBgKUfEtdeYvViLnFxBuToGKsqzXFxt85SQq8ADvA== X-Received: by 2002:a05:6402:138b:b0:46a:3bd0:4784 with SMTP id b11-20020a056402138b00b0046a3bd04784mr7607965edv.7.1674043720481; Wed, 18 Jan 2023 04:08:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 07/19] repack: fix leaks on error with "goto cleanup" Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106335 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 02CD1C46467 for ; Wed, 18 Jan 2023 12:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbjARMrL (ORCPT ); Wed, 18 Jan 2023 07:47:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjARMqT (ORCPT ); Wed, 18 Jan 2023 07:46:19 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1FC423D83 for ; Wed, 18 Jan 2023 04:08:43 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id x36so14673146ede.13 for ; Wed, 18 Jan 2023 04:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tR+FPXh6Y5O5wMgic69DBql8cZiGwfBcWV0fgMBKx9s=; b=CpRYBhq2PykT8p/AUtkyHy5tfCyexEVnY5ICAlbvmXCB82J1D52JiVai7rAqFH9lvY NUezSzwfRZoUkbaj3T6umAtAnzYPHacIWK9CGD62GW1FdfxV66gjjGO3HOZYrfBFlxAu 1qAI6fyr39Jn5iePoI18e9Vjptn6o6cpiw/02jtj98RqaR1rbJJCgDtUKPwciB6pBEAD husBqoO25/ePUHySvyCtDDA9DMV5Ybw4kh5Lft3Xuxs6sf2Q3j+R6Ea5D/ZdKI6Wsfj6 30G3pI8Pte/j+PXO+7uCyQuyhB4/EtpbXH/1p0a6qlSpf05sN6lWq2R92zWWVpa263BV AxNA== 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=tR+FPXh6Y5O5wMgic69DBql8cZiGwfBcWV0fgMBKx9s=; b=RH0ALi6ZcBBkawDNwoI1sgBwYOXAuOs+eM7enTSSYKh/SUZTqDlpQcEu3ABDiGyB8A r/9D/XBxw5CtGQZo+Hg+t/6WvBI/3JwM/vLNSx9pN9yEk0D7SdsRcwTG7lWL7lA/bwVD pB/NhzpMC/CkBkucL5APRcXoHb7dDtL23UaZmkBz5W4dfcrbh8amuejPkzqQOp76y+qH Z5+CptnbEmEfifhGSN+4kXQXqRvg+SfF64+f10GMa2+IhaeNRyJrIC/zUlBlSiawEK9a rGvP6x212Dw+Ap4AvxzL4jtfmmFsBJKMB1tkdSGW10vRL3q898Ga9VIysBoPz50Vv3Nj DBVw== X-Gm-Message-State: AFqh2kqpebBPtNS8A/MSkzhE0f6v7YtCeRxxmwDT8+5mEcT4BeC/usdY TB+X/DX+49CrVxLJIYSEvHsO5WnAD55WgA== X-Google-Smtp-Source: AMrXdXs/tGbJxB1No5ee0GWq/LC2J+psTUKd/9uWIwBxLRLZYOdYKld3Po9xfTiymX+wKbJPMql9cg== X-Received: by 2002:a05:6402:1f8b:b0:499:b4b1:5266 with SMTP id c11-20020a0564021f8b00b00499b4b15266mr7602920edc.40.1674043721401; Wed, 18 Jan 2023 04:08:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 08/19] worktree: fix a trivial leak in prune_worktrees() Date: Wed, 18 Jan 2023 13:08: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 We were leaking both the "struct strbuf" in prune_worktrees(), as well as the "path" we got from should_prune_worktree(). Since these were the only two uses of the "struct string_list" let's change it to a "DUP" and push these to it with "string_list_append_nodup()". For the string_list_append_nodup() we could also string_list_append() the main_path.buf, and then strbuf_release(&main_path) right away. But doing it this way avoids an allocation, as we already have the "struct strbuf" prepared for appending to "kept". Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/worktree.c | 6 +++--- t/t2401-worktree-prune.sh | 1 + t/t2406-worktree-repair.sh | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 591d659faea..865ce9be22b 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -173,7 +173,7 @@ static void prune_worktrees(void) { struct strbuf reason = STRBUF_INIT; struct strbuf main_path = STRBUF_INIT; - struct string_list kept = STRING_LIST_INIT_NODUP; + struct string_list kept = STRING_LIST_INIT_DUP; DIR *dir = opendir(git_path("worktrees")); struct dirent *d; if (!dir) @@ -184,14 +184,14 @@ static void prune_worktrees(void) if (should_prune_worktree(d->d_name, &reason, &path, expire)) prune_worktree(d->d_name, reason.buf); else if (path) - string_list_append(&kept, path)->util = xstrdup(d->d_name); + string_list_append_nodup(&kept, path)->util = xstrdup(d->d_name); } closedir(dir); strbuf_add_absolute_path(&main_path, get_git_common_dir()); /* massage main worktree absolute path to match 'gitdir' content */ strbuf_strip_suffix(&main_path, "/."); - string_list_append(&kept, strbuf_detach(&main_path, NULL)); + string_list_append_nodup(&kept, strbuf_detach(&main_path, NULL)); prune_dups(&kept); string_list_clear(&kept, 1); diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh index 3d28c7f06b2..568a47ec426 100755 --- a/t/t2401-worktree-prune.sh +++ b/t/t2401-worktree-prune.sh @@ -5,6 +5,7 @@ test_description='prune $GIT_DIR/worktrees' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success initialize ' diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh index 5c44453e1c1..8970780efcc 100755 --- a/t/t2406-worktree-repair.sh +++ b/t/t2406-worktree-repair.sh @@ -2,6 +2,7 @@ test_description='test git worktree repair' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' From patchwork Wed Jan 18 12:08: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: 13106338 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 07D38C32793 for ; Wed, 18 Jan 2023 12:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbjARMrP (ORCPT ); Wed, 18 Jan 2023 07:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbjARMqV (ORCPT ); Wed, 18 Jan 2023 07:46:21 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62178C908 for ; Wed, 18 Jan 2023 04:08:43 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id vm8so82680329ejc.2 for ; Wed, 18 Jan 2023 04:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1S66g0/FOvoaQegikCviNJQ9JeEQ/H1N+dWenM7mios=; b=m5I+RU169L1uXGvDpzfcQjyzRkf7hVcIaYnYz+yByzM36sg35g8v+wvwZ0NjVTpsNL Z6NnZsqVeUs99usHdQ7ZfJ+OCTvA/ckqPcMpufwZfOWxM8h5udIjPoKySG5nld3PEtBo kNkIh9fh6B/yRUrk5gOA4C2KGpJME9szs6jn7Z7HkM2bwFHyu1+Eh9XuUtjyhO0R6Skw Ull+AxN4kLOSF3F1QlXsBzjVtVfJ45UUhk/A2u95FSmFl+YyU4SEhP6Lr139rJRG3s7n eJt+TU0yYwdQm5+alE1sK/WDNFWs4cn/5HH7xHDjQrZHNxSDOe6sVjdwk2yFEw0AIMzg HqKg== 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=0Dt5vEiBo0+mqqsNUEqeBgEmaZEYMjYVIxtCMfjx6d1NLridsxVDBOvW+coa5gGy+b srPvj/BzMkT4w/QNmsw9SqOkJErcrzdxY17YZLWg97JsPjvuTbRFkbi0KfcJbsZsSykm 4M2AThHerkN6C+CFXzHxquqxWK7oubtmq5XL+lzEPKiHatyTJ9JvtaUrW44Bf0wgxacV PWGHNhUlGvzg8EfY9v29jAccPSSWf4TZKRUej40HMKhEHqWincm1pufMnjWBF7rigIj0 nFOorl+Jhn+HY7zCmyyVN7mB4kx5sKgPd0mk7Z3M8/YMFKL1tjSIflJPXOPyagT7cucz HCyg== X-Gm-Message-State: AFqh2ko8gc+U459+/jSLdkxmNKDTzXTpaMNjH3LMns/necn/SZNpsDJ2 +X+oLf0Sj6Xl8pfXTLbylmBV18olL7udIw== X-Google-Smtp-Source: AMrXdXvwHm/Mjq/D8OrbmEAO5sT8By58cb2zDFfH8l/KvI1GwTD/PY4Xl082URDsPESr1+Ors47Lqw== X-Received: by 2002:a17:907:8b97:b0:84d:39ba:368b with SMTP id tb23-20020a1709078b9700b0084d39ba368bmr7866146ejc.75.1674043722227; Wed, 18 Jan 2023 04:08:42 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08: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 v5 09/19] http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main() Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106334 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 0B650C32793 for ; Wed, 18 Jan 2023 12:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbjARMrH (ORCPT ); Wed, 18 Jan 2023 07:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbjARMqM (ORCPT ); Wed, 18 Jan 2023 07:46:12 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1625C67A for ; Wed, 18 Jan 2023 04:08:45 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id v10so48119058edi.8 for ; Wed, 18 Jan 2023 04:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i/TBun5atiNc/oQ2kl9/mKAezutuVYs7tQgzxFAmUZ4=; b=DfYpdWUn0N56xNfs+8iGrIUXwN6sR24GJiTkeQxuyu+uEurKFToy2+Mv0RbZ8Ug7Cu acIcun1SRQeyyE3YR+Ca26AK6n84trkXVNnDHZtPuvomxXaZXDRFmHKFmkvyK6+hWiqy IU+nE2mFGILh/CIxAi6fX28fzsycwxkpE/DsXbuQPo57Cy+6AUBGlab4QICJeE+AQgRj nJzbh5VJ6zI6b7PRabqSzp5ugKMqDoZ27W8poQVgLyCF8MusKaSBKFgW9u8g6uGJ5WOf 20ypSH2BGWi00Xv8TsnKvJQa9z+A/bB5E7s0RsgvXoOfw3SQVBX8t1XUp41TXmtRv8qX LSfQ== 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=qIDQVOia3gdWujXVbg3n8osjIYdLII7sOJvrY82Di3bcbIC3eFGLew9EtyBLoKNsqU UDUyyONxWibb05aa30jdh46viXYsUnUrq3y1qBMSc8yFzf3xYdnBBjesqGduAqtDg/Nu An4Eef0GJYsE+lUiBrO8jdwdVci3Q4Qe5dkmZ/2hNGpCKAVMq+LKCHMjaKbhDd2PMoRC R9o65V8tkvUXbqR3YpdUs5kYkIX+R9Xh4Kthuvqay6Tw9+z6aNtW1kG+4xoYBZJISy88 WdFZVxCmXQur2Ycba52ThI88IZ1EKQEUUBJV4V83+Z/AWgKbkl+FebJfJe+rLHoJnjwY y2gw== X-Gm-Message-State: AFqh2kpTs2eamrz5BjN2+dKDBYc+6KmVFja8e/ol5Qbk7RDSXnOvf9KM 4bbdPP2YJdzBAQ0gmr1qIgu3EhyaSs7aUw== X-Google-Smtp-Source: AMrXdXs14dsBqvFGlYpUgSd+18f7NSkvXIlMm/kCzx4upzUz4VeeMxfcO2wpz/BhOQFpgs3D0lhUzQ== X-Received: by 2002:a05:6402:1f87:b0:49d:221b:4b3f with SMTP id c7-20020a0564021f8700b0049d221b4b3fmr7023221edc.21.1674043723357; Wed, 18 Jan 2023 04:08:43 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:42 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 10/19] http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}() Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08: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: 13106336 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 C5FD2C38147 for ; Wed, 18 Jan 2023 12:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjARMrM (ORCPT ); Wed, 18 Jan 2023 07:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjARMqN (ORCPT ); Wed, 18 Jan 2023 07:46:13 -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 D17FA1DB9D for ; Wed, 18 Jan 2023 04:08:46 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id y19so15755739edc.2 for ; Wed, 18 Jan 2023 04:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J2fJJud2NPAFFQ9AJyYBbG+qE8iKqwaUyGWWhxkOPUM=; b=YIeuXamOH2M2fM4koi43DA3gMnmc104ijJWkowuZO/fSKDmRbST+BQ0qxVM8lHl1Cj LAcKuNkr6+6fD5tDWE9n2cidMmSJRzlHwTaywfmX+Bw0EZi1eHWYZw/V8ZdUYlo2Je/9 OssighjBcwdyfQvCV+y6d8xove/ufI9yX7IGBn5KanbRDrwPEAfgNEgWhGzbNnlq3VGq NLZCF+bfFHWITiRkL55nNRy7TYF8+qaA5CFwiIOgx6E3jZBRRfEN7kb3vQ+7mLcAXOZG uqu5LvxTZzLQMgdKdDrpwB0yXkqOUkk5hW1XhxJWjwTbz0M9oyjRQKeUaaKmc8RUflLg YmaQ== 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=OJ54E1rhM9VWaB+3sFetapYHf7+db32V3/DM+4lRaw78QomsmXIkxTubpKRt46hTbF 3x4DwTifGm2IhhhMaNweC1vZ0vUvAq99NJ3pXaH3p/JnBRsLIiKE50aS3e7dLTJMo8xK f4r8CWNHDaN/YD57L03TRO2NizcpTZMWXfdtk+yzYLsv+bRueMFiA5E6xAuuFkiPN83K 06euqWcPT+PAxRfjeXCMnqNeqszHERqdyi+0SGcLw4NGUhWz89oJE6T9546MzPyYi0bW 0DIwF8UbNs+ZiCBHyqYQRK39jVs1BcOPd6QE9Wpt54kWcO/8QUJ8xarZKI+5u3pcv/UZ 7vpA== X-Gm-Message-State: AFqh2ko2i93rCvU6GpqrToQERH6eybyw9QKKaY9fs05PblSZzv5730Yr nGfSya+bNpFzxlLWQHjDjnyS8dGenp2/Zw== X-Google-Smtp-Source: AMrXdXvSewyurShwgltlKzx0/nYgEtPZdxs1fhLHmcwkOwZDRAsYC+5FP5DPQ+9ZlqZwIlk0yuraTg== X-Received: by 2002:a05:6402:60b:b0:470:25cf:99d1 with SMTP id n11-20020a056402060b00b0047025cf99d1mr6974941edv.31.1674043724266; Wed, 18 Jan 2023 04:08:44 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:43 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 11/19] commit-graph: fix a parse_options_concat() leak Date: Wed, 18 Jan 2023 13:08: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 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 Wed Jan 18 12:08:25 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: 13106337 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 26C23C46467 for ; Wed, 18 Jan 2023 12:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjARMrN (ORCPT ); Wed, 18 Jan 2023 07:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbjARMqW (ORCPT ); Wed, 18 Jan 2023 07:46:22 -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 D4CC28F6DD for ; Wed, 18 Jan 2023 04:08:46 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id b4so29827259edf.0 for ; Wed, 18 Jan 2023 04:08:46 -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=LaKkzfEvHAgy6RdHMSTSNrOKBtpWk8K1VmZ6KXIrTI7aRxtbB3RKPQvDejoE7Bcjzq t9v2zPojHEFnc9+uBYDeNovfWVInJ0vdplW5MgmIsiGLBnZKugpnNShjB2C3lEnhskTY UW0eDgdHPPo25qyR47vinrjxlDR8E7wmKqT4F88NG2sGztUdL5mSocCAgXN8Qd8Bp7pz 2PyFM27vI6sqMEJHO7KOTIqnsfxfGtWg5aNdAQC9sQZIZgP3ToZDBzzn252GNdyrzo37 R4giaQRceTPJTJuVC4YU72gLJSuXjffkpAC/CAC97CXixS9OoEyUojU+B2XKKqgMr5SS 0Zyg== 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=OkE8CfDpf3mn45Ami6fKZQOSrPoMKPERyYYM+bfhAScZK2nNw7PdMxz1Jz8OWcQSpO iUAAX6FKljOd0Kmnh1hx57is0xoJuBCFMxHi98BkA7dI+7Z8dejEgTHHZTox5DgRHOX7 XFOODeuX09ij0SDCWuHPH99IKu0sQ723xetbre3imhvp1y2Cxi+xMWLp4zmMpZzRdOFV Tq+3U98L1bdeYLZtDtPRGNbIUCzAVcGGB0CfW2Km+Wu8MYguiv5P0Ee4LAkR3H0aMpj9 wfOvssEG046KymaJ/ptBGS+ljGD9cbmlfj/fU5u9DIs5F3zaZb/ZeEcOqjCktGH4FAGb yVsQ== X-Gm-Message-State: AFqh2kqtm26dNGjAZOzD15H32EZPUjTA+c67waetGlnBo84BRQlYVMGx Jskr0oXXV8HD8g8WgQ/z6/Mv+kmOzWE4Ng== X-Google-Smtp-Source: AMrXdXs91912SGg0gEMChpuXTxIbD1mK+I76KAq2xMP3yPX/eRyW1aOwbPzxCcOkjRU3UmzD+0Exjg== X-Received: by 2002:aa7:cf92:0:b0:48b:58be:472c with SMTP id z18-20020aa7cf92000000b0048b58be472cmr6429051edx.18.1674043725089; Wed, 18 Jan 2023 04:08:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:44 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 12/19] show-branch: free() allocated "head" before return Date: Wed, 18 Jan 2023 13:08:25 +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 Wed Jan 18 12:08:26 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: 13106342 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 C8196C32793 for ; Wed, 18 Jan 2023 12:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231138AbjARMr3 (ORCPT ); Wed, 18 Jan 2023 07:47:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbjARMqY (ORCPT ); Wed, 18 Jan 2023 07:46:24 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44BA8CE58 for ; Wed, 18 Jan 2023 04:08:47 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id m21so49308942edc.3 for ; Wed, 18 Jan 2023 04:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TVTn2r0i+8AIzxKvh7W+2HtTrXcgAylSzXmEKCHhhwo=; b=hYNb7HC+eLxft5xsM0VOF32zmY+3Jl7Ve4iwtkGcsksBmSdnv0D82HTiYFOMyma63f iE6L+mmMSF18gTcmecCMYqyHo5FfFUNtdnXW0iRhF0O+K+HRbEH4UjvC/Rj02IqTFsQm h+BLyei/JqtQaEIzb92VEEGkiXyOuYQeWAmJDm9GFdbPfKJvEtvsdCkzmEZrti359HpF 8pYrjnJOW/3Pe6EydwmmvxrSddIU1s4fuJo45plZP4PHwWOgBX1uVxNvLNUkIKCRumVd AsCwepYruzIuvju6P6QeqeeyrHza0D++5vOtxmQL4wfpnW9iGeeGQ5KrPV6SS/LY/L4p 2huA== 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=7tddWhxcLPW+PWEpY39vEjk/z50OBk6FMf4G2AJqTKEmx4dGpu9Slv2sEmIg4Wq1jM drSDp7ZBKG29N9WDRNSZsAPPxCAgK6gXY1GVO8Z/uOMhbjgt1y1U0opZjQaq4U+FFWXm vnw+bacX17Cg/R2v4hdS9kgoziHcXTi03nqY0gaP6z/6L2Kh5zKdFyCqfksbv9tpP5Nd 3SLTuYY+vgfMChamDTK8JXgCPE2cVjbKmk4rfHlaQBSCxZ3IeGxx7rmjs0mtQ4BOC/Tl N2IcTZLsPYAQd24aRwy4dlvWAeFkuEagZWyP3rpbbMm43R4R70JH7fLUni1VJ0hmYhd+ iyyA== X-Gm-Message-State: AFqh2kpFc86X/EOwsKGEcNLQd1o+jGhnFyRPidtRExcu44Bi1rlli+w2 l694zo0V8t6VFXibFMWaRvxrYxnfT5y+4g== X-Google-Smtp-Source: AMrXdXt8tCwrM5ATCxp93J3F8G5h6EC5NaTXsvKdEbG4LxrKp4XAF6vfmhPRz+AM3bGXEi1tuIm0vg== X-Received: by 2002:aa7:c0d4:0:b0:49d:9bd8:6253 with SMTP id j20-20020aa7c0d4000000b0049d9bd86253mr7439304edp.17.1674043725938; Wed, 18 Jan 2023 04:08:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:45 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 13/19] builtin/merge.c: use fixed strings, not "strbuf", fix leak Date: Wed, 18 Jan 2023 13:08:26 +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 Wed Jan 18 12:08:27 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: 13106344 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 5C6E7C32793 for ; Wed, 18 Jan 2023 12:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbjARMrd (ORCPT ); Wed, 18 Jan 2023 07:47:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbjARMqY (ORCPT ); Wed, 18 Jan 2023 07:46:24 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D47608EFFA for ; Wed, 18 Jan 2023 04:08:48 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id v6so49267971edd.6 for ; Wed, 18 Jan 2023 04:08:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2XYzzDZOSUDBBe1ZGCFYhwfsb6htnueNwPuJIfYkT3Q=; b=RC1gXhAtnzvL5FA0asP7Zq4fX2CfLFF6hZrhxsA9CAGJ49y6Y7gj0JCPr4tpqm1bVJ lkm0lH1izoiogFvKkwhYVFHhv+tCHrnWX6IFVOnwncul5hiBf4NCIAzi3g+549Ioa9nU oz597l0yYfQmRyTR9as/CubBGFBVc6Ele1uGwNwp+PKaI8UnseSEeevHVOssYml48TmB lHuOtA915GbbSABaGW9yg2MXVMjWIlWC0DH6tCWy+im86GV5HjuYLMH25bj6W5H1/PD+ M8sgB9CxykYuOm67lld8rU9NBskChb/EQLgopkhbdI6BJlP9R6k5JPg8iSjLyoZEYgel Z5JQ== 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=pTd+jjmMt8BlO4ej0BBOXBCIH2BgBt+/wJCKIEbVDIJxUUTACnIt8wWOoX7pgqQaFX ogZHkRJqYb2nwaXo5x/QbHbvQHnIHTWGqUooqBZOW7A8GSyFPkfqq9cn3XzfAWTbCoCG Z/8KdF3saLinlaq2gvjK20mccrFte0mLMc5j9OYyQn3RoJuW8v07WDcjGVcZFtVw2Mvx Wgwzr4wY4Na+XJ4XfqG3/KiZWHeaAkZnEngYTvZuFXjrb4K5WnU9Yjzxq4Sw3jA6zFDj S3A/YsVUMPvYLwb5rJ2HBh14lJrRRp+RX06a4/B5BlDhb2NBiV9WUJZXWMTHZFt2dnCH Z8hA== X-Gm-Message-State: AFqh2krcBoUMdvRQSQHvr0Lc+KpS7N/XeqUL9xC88f6h09jQYlVhDaag TJepiSTbfwYGMn8if4f3Ku7ha/w+hsJ5Hg== X-Google-Smtp-Source: AMrXdXt/hl0HHU52RoVPZrFUoBzlOcVZ8ucmq/P90MJr7R42PDSEDCQERyUagCSWci7kKYzrX57mKg== X-Received: by 2002:a05:6402:380b:b0:492:bf3d:1a15 with SMTP id es11-20020a056402380b00b00492bf3d1a15mr7504279edb.1.1674043727071; Wed, 18 Jan 2023 04:08:47 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:46 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 14/19] builtin/merge.c: free "&buf" on "Your local changes..." error Date: Wed, 18 Jan 2023 13:08:27 +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 Wed Jan 18 12:08:28 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: 13106340 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 9A5D5C32793 for ; Wed, 18 Jan 2023 12:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbjARMrU (ORCPT ); Wed, 18 Jan 2023 07:47:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbjARMqW (ORCPT ); Wed, 18 Jan 2023 07:46:22 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37838C93D for ; Wed, 18 Jan 2023 04:08:49 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id z11so49357539ede.1 for ; Wed, 18 Jan 2023 04:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cNAdvILvYHVHQZagSiHg7GRtC8IV2ThQrGptssEb6H4=; b=TMU5xZl/M1l8ObwHQ6Dm1dStk0wfvKm/ApgQG7n+1aLqGWcymxPadsTJeb5NWEd90t UTjYY+amB6NXnvDgsJS51/VCdRO9J9fY9qDYMZpXAeSfP6XkxFTwf6t/N8C315q7kiMp wnGzEzoMXsjpBzlo0kh4pdS+lRc2A3mr+wm9lAV84SxYH2dr+bxuZLKqP/XkfOUV9PXL 3DII2e/q1EZe7V4HzvL1CB7Z7DuxxBvZ//6PTPDX5zHeQ4GWGXOeAqT1jFjg4yZ0ThEz YXB5VmUIhiwiKJFtNS+PYFIqz/faCA9FT2TC1uJGEUmj2HdSPHKZQNFD3JM66xR3EFUA c+5Q== 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=U6SleUUCTZ3EOwNmVileCj7NRM8zGgx/gaAXjvO6/L55F4ojtATu/tZ+zrqFcH6vru a42SvKaKGzrWIigB4PxNGVOVKqPHlb8g81TIO7XSZWMBJxM/PUaG6xCceinN6cJaPPNn KgTdHnQFjiyGPOtyZyZKOzPlXmmPluzJ9P1m+47hJVedlGp0BneV5F/D6Hrn48bVuLQA oD+W6pprDQyIZTYW9JJX3yNn/gS3gTndB3u2Rap10WGvwF65E1LgvLmn3Pw3koMKJu2c Ud+ZExtLmY8tyzs37okWkLa/jEmMsId+4utAJeUKRqTYW+2glmUZ7PYSxMRQvy300IBT vh8Q== X-Gm-Message-State: AFqh2koVCbu9/DH9F0lkTPIcbSyP4zG119Oyq2FOMLkc2f8X8eusE3dg /P5Ikf10F+YREH277tjeaoZUBtG9iXhkFQ== X-Google-Smtp-Source: AMrXdXs1PtVuqqRUsR/3nlD3hwSH90YMBLId6wVH7mHUgdDqb3eSWSjjuj24RQCCeylOH/A0DoZ/hQ== X-Received: by 2002:a05:6402:3894:b0:49e:45a8:1ac9 with SMTP id fd20-20020a056402389400b0049e45a81ac9mr3122177edb.24.1674043727862; Wed, 18 Jan 2023 04:08:47 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:47 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 15/19] object-file.c: release the "tag" in check_tag() Date: Wed, 18 Jan 2023 13:08:28 +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 Wed Jan 18 12:08:29 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: 13106343 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 28B56C38159 for ; Wed, 18 Jan 2023 12:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbjARMra (ORCPT ); Wed, 18 Jan 2023 07:47:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbjARMqY (ORCPT ); Wed, 18 Jan 2023 07:46:24 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E9F917C3 for ; Wed, 18 Jan 2023 04:08:50 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id v6so39707988ejg.6 for ; Wed, 18 Jan 2023 04:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q+BUcbwSdm8pyvoCjUjcaG+1v3Vw0KRT8qqUiTgW6/o=; b=cof2GB0B1Kw8paj1EF+ycDo0t+aXRYTD2YFIQV87VbeEXPxMkjiUVjVHrDX6gpDC3W DiTMJRSWfT31uZb0q//UCBJk2djX5YO2W4RLf+zBuH08K4SoW1KyHz+HWKvLk3Rs1/XN KCujIA1ZJYXjOP3qpojBPdflJWILVJglEgPlSHMKptRQ2Na1/Ijv8/TM2iITzKJ0mbLj m9Kt/vi3rvnIXC/BLbO35/ipKUWONtD9C/tI63kFTToq8q1525x4HC+dTF/rrJi3UxY1 F2RrSINvAbMVB187C26SZC60YzQBwIvlbNYtJMEFeISRdU3HzuCbZIooGrthL0kSIhQT uvQQ== 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=YOXHNUeC8MTm0SlT+IHuyFtpdE0owQyVUVhTDFPjVLqLhBN4PytfFSDZvs3YopOn6N qp4jGrAooZnwmJzcfC0VNfRr5EqAwwVMZfVcedte9rWlmXU/hHeSIjkCs9LVC1plLY9W 0H9WNde4aUDI79a4UvjVbqwDjvBofsckuCuR0G6UcNkwfHm8V6jAN3pWOEC0yBp2TPpw OKY6DFXl7kWjM93ERNpFkjhVvKWGC3VDfsvxq95AsC7cP3mSQocf558SwznMNL0XFo4T uK2QSa9KSfCsE3pane+eTE+umnP13TNWFVG2gc/SLZ+88Cu60yG45qsd+d34C5As9h5u KgKA== X-Gm-Message-State: AFqh2kqMDkiKU39o86vrg91Q4R/dKQXwhfSAVbTnJQNKhwQQ71nqoqrc aku6Y2gRA1Dc/wmyJbwgAdIQBAEQQq2cFg== X-Google-Smtp-Source: AMrXdXsA0iYGPUmBtzljzjifzuH5oLfX8bA+P9nKoH8MUdGGpQM5qtcNOU1kfLQSY/rgPDT9bDRmRA== X-Received: by 2002:a17:906:80cd:b0:86d:b50f:6b00 with SMTP id a13-20020a17090680cd00b0086db50f6b00mr6028851ejx.43.1674043728960; Wed, 18 Jan 2023 04:08:48 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:48 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 16/19] grep.c: refactor free_grep_patterns() Date: Wed, 18 Jan 2023 13:08:29 +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 Wed Jan 18 12:08:30 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: 13106339 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 EFC3BC38147 for ; Wed, 18 Jan 2023 12:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231124AbjARMrS (ORCPT ); Wed, 18 Jan 2023 07:47:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjARMqW (ORCPT ); Wed, 18 Jan 2023 07:46:22 -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 D6FF3917E9 for ; Wed, 18 Jan 2023 04:08:51 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id s3so11169291edd.4 for ; Wed, 18 Jan 2023 04:08:51 -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=jnCBy6ImsH86DLmhAc79BeulAqFdPTNx6cHDtle/0y3kz/vrNYRpf+oyhSMFlSNE4v h79B+srSPZOdar35HOeD/WAE51RwsHIG87JN+r35eW4D1NLPRFj/un++arNjdzGmcbPy QK/lpGe8wZBqKp4Dal9FrgQd2IyBEVIioG9Zuy5I3gUK/BQ3Id8iSmDND6chicyLKPWH XncXUgjNcs5GKm6KuuMDNN5eQjT3biZwPH4G7rTW87XTniOi5TgJgfwSs5WVdFF2/UnO o+tZM+iBtxk9d2cBtFw+YB9gUyo80rtS1AT2nEu3kOuK9Ce8noVEeScRxs5qBzbksbJC WpoA== 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=4fWvXCI5w54JFqt/hZ8vmNpeNRxcN18bOSIQmG/RlD0owmVvcTp7eGGjBZ/xfH+QFw +XqnyZxrvMhpdKDtRCVM0D5bMgbTgsA98Sn0ZL4fQRpP3L7VgIH9UQHyViQREkrfTEEy x8FMrpw94zLhygDj6r2U7757o7SEtRnCeZc9bVWTcJgS+5gcwp8+tx/Mdkt6UYETXQlj 8ERqm2je9ZHtWXO2vqCCjfD3P6yxyieYM0i3Rl905ChJxUw54G/y57vXguoBJLileWic J3IixFTEbqdba3XGpI2zsYOhRpOSQ6YSS59WOPn9OkHiEVPF+R61T5N9LN63EsHxUo93 /1GQ== X-Gm-Message-State: AFqh2kq1emPId5loi7eBFKDCRXPj/TtHJ5LlJrEr+B53TxCzvmx3mfqb IBuY9reBojiaAVjiR+pezKG9dEE0FgBygQ== X-Google-Smtp-Source: AMrXdXubL2KltHFCIVMcTwQIFSJKeGcAHTjQRhBzPBWSMTXn3T3OgLuKehI1cEXNItVdkV9kNBmnww== X-Received: by 2002:aa7:d310:0:b0:499:e564:a1c with SMTP id p16-20020aa7d310000000b00499e5640a1cmr6086817edq.11.1674043729865; Wed, 18 Jan 2023 04:08:49 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:49 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 17/19] grep API: plug memory leaks by freeing "header_list" Date: Wed, 18 Jan 2023 13:08:30 +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 Wed Jan 18 12:08:31 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: 13106345 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 220C4C32793 for ; Wed, 18 Jan 2023 12:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231140AbjARMrg (ORCPT ); Wed, 18 Jan 2023 07:47:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbjARMqY (ORCPT ); Wed, 18 Jan 2023 07:46:24 -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 D87C394306 for ; Wed, 18 Jan 2023 04:08:52 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id x10so46469539edd.10 for ; Wed, 18 Jan 2023 04:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7kTWzCHL6Dj42pkbke7fDrfNF5o2r53qWt9KXITmkXc=; b=VBor+BSy/DPXGzekg/BirdR/42RHfZKDxU1vz2O7aJekw4hQjZ9gd+MeLwtViNhxqX ahq9cHVie1UfGouWkhQ8rXDdaFiSJnRahMyL06nJp+3HwIcxoxRXMub0wOqEDwzZtuM8 mZ3oc0CE93iLfxUCbXtVndhT3FxbpDl6fjKmf8bVaf9iSV+pHm/fm3YsI+lWQCKSsJ8R RKUcgPGtyln2wINEvUjC6tPfxZhp3PMrn1yCXJ1xdi1rd5iyKRsVSNJ06OR0uFgJMF3R phdygiJeQ6aa2UqGkG7vJPBbWQZhDx8UZ2vcIbI4Md3i/bJBRmHEFe0WDgm0MXt8Xnhc 8GKQ== 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=4SRuvNybGIEHWuddamOdBR+niyEE0mxy3NpTGeGBITTmWfi5mzc4E2vVcwyQtj7RUK N5iH4HmuCDp5pKVaz+hk+cabwucucMnf9VgGqZWpRpbg2eyv3mXATwB4ak7onzhc/wLS iSc66JVwQ8sBHZ1LzO8fN2zHkMg6G1v8BRWs6JRn2XrsNrHLLOiRtjZpixgShVFWYfKW Y0ozQPaU5in7jpNpb47UXdrTP2Da1Bqz6PYayrS008VhY7bTtzQpUXK3PFdv/2ooLXWj hJNNzQpVdkOTQbPMsYswfdl89zPYd4xmcbMYDoAr61bfn5a8svjXiMzJ70XYGuK7s4MN SsoA== X-Gm-Message-State: AFqh2kqdcTK1abZErPoGQmUniSOSsavL+UzGaujMebN/lHzKjq6macyT JsWp8Mm+w1mw/QGrhX4KtJKErRbD1wnjlQ== X-Google-Smtp-Source: AMrXdXtCCm7miM05eTFydlwYUMx2A5RonOB9hJ6Gvwym0F/mdg2FMrbzlT8RiXccI7RESi9kJL7x8Q== X-Received: by 2002:aa7:c0d4:0:b0:48f:acd1:8da2 with SMTP id j20-20020aa7c0d4000000b0048facd18da2mr6975921edp.27.1674043730889; Wed, 18 Jan 2023 04:08:50 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:50 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 18/19] receive-pack: free() the "ref_name" in "struct command" Date: Wed, 18 Jan 2023 13:08:31 +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 Wed Jan 18 12:08:32 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: 13106341 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 033CBC32793 for ; Wed, 18 Jan 2023 12:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjARMrY (ORCPT ); Wed, 18 Jan 2023 07:47:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbjARMqW (ORCPT ); Wed, 18 Jan 2023 07:46:22 -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 D949494C81 for ; Wed, 18 Jan 2023 04:08:53 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id ud5so82759370ejc.4 for ; Wed, 18 Jan 2023 04:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UQVKx0iy6w2tlH8jJSWhs9XAxMlzpSUXsOXqhZO1U4o=; b=ad2vlmUcdqzuJJh8tDGaLHgURjc1J1MUAaIezHYDsyDxWOHLofHKROwhWyswLDUdFc 7lwiw9FBZrRo/szmhvT54AwsYnXV+UinfSZcY/he/ZbJd2wlOWTidq4Qm+hcVh73GDlM Y9GPJuRHrNQoIdTWWCqdO0XuQigaGH5Vsif4rr7+tiOwC1LW06bKMtzfjFjwWzKMJXKE gcmyzmJMeB9thD0p6BKNJmHic0CpBQ9So9JWyN9ZGT36mPCQs9J+9mZEx/DSSh5HS4dv 3ELR5YaLJAzBeQiSKL/iy4Uyv5mSW3umpxXcAB/Uc+/OVMUO/Kzkm6M5rBc/jIUmYPZy 5RGw== 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=dyKLQPSkNtDyA6hchKcSm0VVUwdAJs2RI9kC3MCqePzZlX7i4+BfH9EKxdw7eKFehf aq8uNpJmTJaxjRGood0vbWIyM8mUP5xGVUQYCipwdcut+Y+PcniQ9UQw5RgdyOktyEsN CceOxgjYR0QEn6UmBTUbyeEnSXDIBIaaLupWrWkG567n90oNZWmhVbXOtykQfxX98hsm BTtKsHmMVJp24+y4vuhuLRCIdt+tYooUKSsnYcmENY6S/GHvZ+YR7PtpQW1Dt+ev4ZtY wvoQ0k3z4EHUNZSM2PSy2x9Q01Ghatq3CXQzYI3nAHPyUhnFu2FNCdEHcBp5Yp1jlC7h aqmQ== X-Gm-Message-State: AFqh2kqi6f4HdRNLTRKUmSH/KbzdqXo+L23Mn5qbuuRgctNzLtMb2PJW BkeentfFGvMa/fcqDJkOaHnwgzmS6rEaXw== X-Google-Smtp-Source: AMrXdXuXfWX0GFctgRW0y754nJQhrCi0H5SinJA5x7KHDzIV6nBUntJHxcQRnuT2U34rE+c7uFYbGw== X-Received: by 2002:a17:906:8154:b0:866:d17a:e50 with SMTP id z20-20020a170906815400b00866d17a0e50mr6509712ejw.70.1674043731871; Wed, 18 Jan 2023 04:08:51 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id b15-20020aa7c90f000000b004615f7495e0sm14120053edt.8.2023.01.18.04.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 04:08:51 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v5 19/19] push: free_refs() the "local_refs" in set_refspecs() Date: Wed, 18 Jan 2023 13:08:32 +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