From 1d679de58e886e134c5569c542667a08f0faedd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 16 Mar 2011 17:06:17 +0100 Subject: make_absolute_path: return the input path if it points to our buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 91ca00f..ff14068 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); -- cgit v0.10.2-6-g49f6