Skip to content

Commit 0f26223

Browse files
pks-tgitster
authored andcommitted
builtin/help: fix leaking html_path when reading config multiple times
The `html_path` variable gets populated via `git_help_config()`, which puts an allocated string into it if its value has been configured. We do not clear the old value though, which causes a memory leak in case the config exists multiple times. Plug this leak. The leak is exposed by t0012, but plugging it alone is not sufficient to make the test suite pass. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 02e36f9 commit 0f26223

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/help.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static enum help_action {
5252
HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,
5353
} cmd_mode;
5454

55-
static const char *html_path;
55+
static char *html_path;
5656
static int verbose = 1;
5757
static enum help_format help_format = HELP_FORMAT_NONE;
5858
static int exclude_guides;
@@ -409,6 +409,7 @@ static int git_help_config(const char *var, const char *value,
409409
if (!strcmp(var, "help.htmlpath")) {
410410
if (!value)
411411
return config_error_nonbool(var);
412+
free(html_path);
412413
html_path = xstrdup(value);
413414
return 0;
414415
}

0 commit comments

Comments
 (0)