builtin/maintenance: fix leaking config string

When parsing the maintenance strategy from config we allocate a config string, but do not free it after parsing it. Plug this leak by instead using `git_config_get_string_tmp()`, which does not allocate any memory. This leak is exposed by t7900, but plugging it alone does not make the test suite pass. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Sep 26, 2024 at 13:46 UTC 84e9fc361dca294629ef0b1e4e2eea815fc5b522
1 file changed +2 -2
builtin/gc.c
+2 -2
@@ -1476,9 +1476,9 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
1476
1477 static void initialize_maintenance_strategy(void)
1478 {
1479 - char *config_str;
1479 + const char *config_str;
1480
1481 - if (git_config_get_string("maintenance.strategy", &config_str))
1481 + if (git_config_get_string_tmp("maintenance.strategy", &config_str))
1482 return;
1483
1484 if (!strcasecmp(config_str, "incremental")) {