From: Carlos Martín Nieto Date: Wed, 16 Mar 2011 16:06:17 +0000 (+0100) Subject: make_absolute_path: return the input path if it points to our buffer X-Git-Tag: v1.7.4.2~27 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1d679de58e886e134c5569c542667a08f0faedd6;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/abspath.c b/abspath.c index 91ca00f05..ff140689e 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);