]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: fix leaking "core.notesref" variable
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:20:38 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:07 +0000 (13:15 -0700)
The variable used to track the "core.notesref" config is not getting
freed before we assign to it and thus leaks. Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
t/t3308-notes-merge.sh
t/t3309-notes-merge-auto-resolve.sh

index abce05b7744a91477a6d11c43501e02e6bf4c734..742175c1308144f4e30ed58d1a9c1e36c2b5d364 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1565,6 +1565,7 @@ static int git_default_core_config(const char *var, const char *value,
        if (!strcmp(var, "core.notesref")) {
                if (!value)
                        return config_error_nonbool(var);
+               free(notes_ref_name);
                notes_ref_name = xstrdup(value);
                return 0;
        }
index 202702be1a78b7bb631952dc36af9a1cb69c2ecf..e1d05ff6bc986a05bc42f02e2e86d78ddedd7aed 100755 (executable)
@@ -5,6 +5,7 @@
 
 test_description='Test merging of notes trees'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success setup '
index 9bd5dbf341fd81a80dbebf0e1fafe623defecfa4..f55277f499dd57661e166bf3487c792df1cb1bf3 100755 (executable)
@@ -5,6 +5,7 @@
 
 test_description='Test notes merging with auto-resolving strategies'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # Set up a notes merge scenario with all kinds of potential conflicts