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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Sep 5, 2017 at 09:04 UTC
6c6b08d26999405a5c67dbabe6f9f232d658fd26
1 file changed
+5
-2
builtin/config.c
+5
-2
@@ -518,10 +518,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
518
die("$HOME not set");
519
520
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)) {
522
given_config_source.file = xdg_config;
523
- else
523
+ free(user_config);
524
+ } else {
525
given_config_source.file = user_config;
526
+ free(xdg_config);
527
+ }
528
}
529
else if (use_system_config)
530
given_config_source.file = git_etc_gitconfig();