From: Jim Meyering Date: Wed, 21 Jun 2000 12:56:33 +0000 (+0000) Subject: (path_concat): Don't access dir[-1] if dir is the empty string. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d447ad210177980a4747a2208a00d001fc7ccee;p=pspp (path_concat): Don't access dir[-1] if dir is the empty string. --- diff --git a/lib/path-concat.c b/lib/path-concat.c index 8c4bbb4e8b..d6dafc9398 100644 --- a/lib/path-concat.c +++ b/lib/path-concat.c @@ -86,10 +86,13 @@ path_concat (const char *dir, const char *base, char **base_in_result) p = mempcpy (p_concat, dir, dir_len); - if (ISSLASH (*(p - 1)) && ISSLASH(*base)) - --p; - else if (!ISSLASH (*(p - 1)) && !ISSLASH(*base)) - *p++ = DIRECTORY_SEPARATOR; + if (dir_len > 0) + { + if (ISSLASH (*(p - 1)) && ISSLASH(*base)) + --p; + else if (!ISSLASH (*(p - 1)) && !ISSLASH(*base)) + *p++ = DIRECTORY_SEPARATOR; + } if (base_in_result) *base_in_result = p;