summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27370b1)
raw | patch | inline | side by side (parent: 27370b1)
author | Jeff King <peff@peff.net> | |
Thu, 16 Feb 2012 08:03:52 +0000 (03:03 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 17 Feb 2012 15:52:41 +0000 (07:52 -0800) |
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>
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>
builtin/config.c | patch | blob | history |
diff --git a/builtin/config.c b/builtin/config.c
index d35c06ae51573eafbddd6309fda3f90ecef35d54..55854bef684752f1ca92d7081d536fbccaed6b1e 100644 (file)
--- a/builtin/config.c
+++ b/builtin/config.c
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;
}