From e371a4c648e72673fcfdf0b45192857dd149e2f5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 2 Mar 2008 07:40:33 +0000 Subject: Fix make_absolute_path() for parameters without a slash When passing "xyz" to make_absolute_path(), make_absolute_path() erroneously tried to chdir("xyz"), and then append "/xyz". Instead, skip the chdir() completely when no slash was found. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- path.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'path.c') diff --git a/path.c b/path.c index 42609524a5..af2716199b 100644 --- a/path.c +++ b/path.c @@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path) if (last_slash) { *last_slash = '\0'; last_elem = xstrdup(last_slash + 1); - } else + } else { last_elem = xstrdup(buf); + *buf = '\0'; + } } if (*buf) { -- cgit v1.3-5-g9baa