summaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-09-05 13:04:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-06 09:06:26 (GMT)
commit6c6b08d26999405a5c67dbabe6f9f232d658fd26 (patch)
tree443c145aa6eb760a414335640c596945b0ce7cdf /builtin/config.c
parentbaddc96b2cbf66fdcde87509392dc8da6a77f452 (diff)
downloadgit-6c6b08d26999405a5c67dbabe6f9f232d658fd26.zip
git-6c6b08d26999405a5c67dbabe6f9f232d658fd26.tar.gz
git-6c6b08d26999405a5c67dbabe6f9f232d658fd26.tar.bz2
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>
Diffstat (limited to 'builtin/config.c')
-rw-r--r--builtin/config.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 70ff231..52a4606 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -518,10 +518,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
die("$HOME not set");
if (access_or_warn(user_config, R_OK, 0) &&
- xdg_config && !access_or_warn(xdg_config, R_OK, 0))
+ xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
given_config_source.file = xdg_config;
- else
+ free(user_config);
+ } else {
given_config_source.file = user_config;
+ free(xdg_config);
+ }
}
else if (use_system_config)
given_config_source.file = git_etc_gitconfig();