From e1bd3bc7b497d58efc1c7a5c56dbc591d5be880f Mon Sep 17 00:00:00 2001 From: night199uk Date: Thu, 18 Oct 2018 23:18:45 +0200 Subject: [PATCH] path: nasm_catfile -- Fix incorrect return of filename only nasm_catfile returns an incorrect (already incremented) pointer. https://bugzilla.nasm.us/show_bug.cgi?id=3392205 Signed-off-by: night199uk Signed-off-by: Cyrill Gorcunov --- nasmlib/path.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nasmlib/path.c b/nasmlib/path.c index 9dadaba8..d228ed1e 100644 --- a/nasmlib/path.c +++ b/nasmlib/path.c @@ -164,7 +164,7 @@ char *nasm_catfile(const char *dir, const char *file) #else size_t dl = strlen(dir); size_t fl = strlen(file); - char *p; + char *p, *pp; bool dosep = true; if (!dl || ismatch(separators, dir[dl-1])) { @@ -172,14 +172,14 @@ char *nasm_catfile(const char *dir, const char *file) dosep = false; } - p = nasm_malloc(dl + fl + dosep + 1); + p = pp = nasm_malloc(dl + fl + dosep + 1); - memcpy(p, dir, dl); - p += dl; + memcpy(pp, dir, dl); + pp += dl; if (dosep) - *p++ = catsep; + *pp++ = catsep; - memcpy(p, file, fl+1); + memcpy(pp, file, fl+1); return p; #endif