summaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2011-03-16 17:06:17 +0100
committerJunio C Hamano <gitster@pobox.com>2011-03-16 13:51:22 -0700
commit1d679de58e886e134c5569c542667a08f0faedd6 (patch)
treec2e1ca640d80925b0cbcd580e6b735e64ff2bde8 /abspath.c
parentb406a2d3e30b1930ea3dc812bd1c4422ae135d14 (diff)
downloadgit-1d679de58e886e134c5569c542667a08f0faedd6.tar.gz
make_absolute_path: return the input path if it points to our buffer
Some codepaths call make_absolute_path with its own return value as input. In such a cases, return the path immediately. This fixes a valgrind-discovered error, whereby we tried to copy a string onto itself. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/abspath.c b/abspath.c
index 91ca00f05f..ff140689ed 100644
--- a/abspath.c
+++ b/abspath.c
@@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
char *last_elem = NULL;
struct stat st;
+ /* We've already done it */
+ if (path == buf || path == next_buf)
+ return path;
+
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
die ("Too long path: %.*s", 60, path);