summaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-01-11 22:15:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-12 02:48:58 (GMT)
commit423ff9bef003b41f81949e7a88d7278b48334ed4 (patch)
tree87cf31398c7255de50608f58048e58260eb7575b /builtin/config.c
parent406bab3811a220400da6a43da71346cbfc466fc9 (diff)
downloadgit-423ff9bef003b41f81949e7a88d7278b48334ed4.zip
git-423ff9bef003b41f81949e7a88d7278b48334ed4.tar.gz
git-423ff9bef003b41f81949e7a88d7278b48334ed4.tar.bz2
config: make a copy of $GIT_CONFIG string
cmd_config() points our source filename pointer at the return value of getenv(), but that value may be invalidated by further calls to environment functions. Let's copy it to make sure it remains valid. We don't need to bother freeing it, as it remains part of the whole-process global state until we exit. 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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 97b58c4..752d0c6 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -595,7 +595,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
int nongit = !startup_info->have_repository;
char *value;
- given_config_source.file = getenv(CONFIG_ENVIRONMENT);
+ given_config_source.file = xstrdup_or_null(getenv(CONFIG_ENVIRONMENT));
argc = parse_options(argc, argv, prefix, builtin_config_options,
builtin_config_usage,