Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
make_absolute_path: return the input path if it points to our buffer
author
Carlos Martín Nieto
<cmn@elego.de>
Wed, 16 Mar 2011 16:06:17 +0000
(17:06 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 16 Mar 2011 20:51:22 +0000
(13:51 -0700)
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>
abspath.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
b406a2d
)
diff --git
a/abspath.c
b/abspath.c
index 91ca00f05f7d648fa801a36b78c749f9d691ba43..ff140689ed2453809e7c3794c9989918e90df392 100644
(file)
--- 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;
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);
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
die ("Too long path: %.*s", 60, path);