From: Arun Prakash Jana Date: Sun, 26 Apr 2020 08:24:12 +0000 (+0530) Subject: Fix #537 X-Git-Tag: v3.2~99 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=33fdbc2216d3e91c9e911ecf4366b09c029346ba;p=nnn.git Fix #537 --- diff --git a/src/nnn.c b/src/nnn.c index 15f1daa8..dfceb764 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -1040,7 +1040,12 @@ static char *abspath(const char *path, const char *cwd) size_t dst_size = 0, src_size = xstrlen(path), cwd_size = xstrlen(cwd); const char *src; char *dst; - char *resolved_path = malloc(src_size + (*path == '/' ? 0 : cwd_size) + 1); + /* + * We need to add 2 chars at the end as relative paths may start with: + * ./ (find .) + * no separator (fd .): this needs an additional char for '/' + */ + char *resolved_path = malloc(src_size + (*path == '/' ? 0 : cwd_size) + 2); if (!resolved_path) return NULL;