config: fix leaking "core.notesref" variable

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>

Patrick Steinhardt committed Jun 11, 2024 at 11:20 UTC c6eb58bfb19a0840841934b91613ea53f0da8651
3 files changed +3
config.c
+1
@@ -1565,6 +1565,7 @@ static int git_default_core_config(const char *var, const char *value,
1565 if (!strcmp(var, "core.notesref")) {
1566 if (!value)
1567 return config_error_nonbool(var);
1568 + free(notes_ref_name);
1569 notes_ref_name = xstrdup(value);
1570 return 0;
1571 }
t/t3308-notes-merge.sh
+1
@@ -5,6 +5,7 @@
5
6 test_description='Test merging of notes trees'
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success setup '
t/t3309-notes-merge-auto-resolve.sh
+1
@@ -5,6 +5,7 @@
5
6 test_description='Test notes merging with auto-resolving strategies'
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 # Set up a notes merge scenario with all kinds of potential conflicts