Skip to content

Commit 6c6b08d

Browse files
peffgitster
authored andcommitted
config: plug user_config leak
We generate filenames for the user_config ("~/.gitconfig") and the xdg config ("$XDG_CONFIG_HOME/git/config") and then decide which to use by looking at the filesystem. But after selecting one, the unused string is just leaked. This is a tiny leak, but it creates noise in leak-checker output. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baddc96 commit 6c6b08d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builtin/config.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
518518
die("$HOME not set");
519519

520520
if (access_or_warn(user_config, R_OK, 0) &&
521-
xdg_config && !access_or_warn(xdg_config, R_OK, 0))
521+
xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
522522
given_config_source.file = xdg_config;
523-
else
523+
free(user_config);
524+
} else {
524525
given_config_source.file = user_config;
526+
free(xdg_config);
527+
}
525528
}
526529
else if (use_system_config)
527530
given_config_source.file = git_etc_gitconfig();

0 commit comments

Comments
 (0)