aboutsummaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-02-16 03:03:52 -0500
committerJunio C Hamano <gitster@pobox.com>2012-02-17 07:52:41 -0800
commit839de2527258879aa21ae7ad425353f06dbb4717 (patch)
tree96c99542c123e40dd65fac8d9f2dbbb64b29e733 /builtin/config.c
parent27370b1170fbd5859e9d88e91be9108e04b6725e (diff)
downloadgit-839de2527258879aa21ae7ad425353f06dbb4717.tar.gz
git-839de2527258879aa21ae7ad425353f06dbb4717.tar.xz
config: copy the return value of prefix_filename
The prefix_filename function returns a pointer to a static buffer which may be overwritten by subsequent calls. Since we are going to keep the result around for a while, let's be sure to duplicate it for safety. I don't think this can be triggered as a bug in the current code, but it's a good idea to be defensive, as any resulting bug would be quite subtle. 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, 4 insertions, 3 deletions
diff --git a/builtin/config.c b/builtin/config.c
index d35c06ae5..55854bef6 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -377,9 +377,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
config_exclusive_filename = git_pathdup("config");
else if (given_config_file) {
if (!is_absolute_path(given_config_file) && prefix)
- config_exclusive_filename = prefix_filename(prefix,
- strlen(prefix),
- given_config_file);
+ config_exclusive_filename =
+ xstrdup(prefix_filename(prefix,
+ strlen(prefix),
+ given_config_file));
else
config_exclusive_filename = given_config_file;
}