From: lostd Date: Thu, 23 Oct 2014 14:53:26 +0000 (+0300) Subject: If you call makepath() with an absolute name it returns a copy of it X-Git-Tag: v1.0~92^2~140 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4b1b156a3b477f242f9cb0984558010c887a5c8a;p=nnn.git If you call makepath() with an absolute name it returns a copy of it --- diff --git a/noice.c b/noice.c index c3d3728f..6b372fd2 100644 --- a/noice.c +++ b/noice.c @@ -490,11 +490,16 @@ makepath(char *dir, char *name) { char *path; - /* Handle root case */ - if (strcmp(dir, "/") == 0) - asprintf(&path, "/%s", name); - else - asprintf(&path, "%s/%s", dir, name); + /* Handle absolute path */ + if (name[0] == '/') { + path = xstrdup(name); + } else { + /* Handle root case */ + if (strcmp(dir, "/") == 0) + asprintf(&path, "/%s", name); + else + asprintf(&path, "%s/%s", dir, name); + } return path; }