changeset 2623:05f39f9d91f5

(path_concat): Don't access dir[-1] if dir is the empty string.
author Jim Meyering <jim@meyering.net>
date Wed, 21 Jun 2000 12:56:33 +0000
parents c570cf476003
children 8d0959af71c4
files lib/path-concat.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lib/path-concat.c
+++ b/lib/path-concat.c
@@ -86,10 +86,13 @@
 
   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;