mirror of
https://github.com/git/git.git
synced 2025-12-23 12:14:22 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
b406a2d3e3
commit
1d679de58e
@@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
|
|||||||
char *last_elem = NULL;
|
char *last_elem = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
/* We've already done it */
|
||||||
|
if (path == buf || path == next_buf)
|
||||||
|
return path;
|
||||||
|
|
||||||
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
|
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
|
||||||
die ("Too long path: %.*s", 60, path);
|
die ("Too long path: %.*s", 60, path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user