projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
08cd18b
)
(path_concat): Don't access dir[-1] if dir is the empty string.
author
Jim Meyering
<jim@meyering.net>
Wed, 21 Jun 2000 12:56:33 +0000
(12:56 +0000)
committer
Jim Meyering
<jim@meyering.net>
Wed, 21 Jun 2000 12:56:33 +0000
(12:56 +0000)
lib/path-concat.c
patch
|
blob
|
history
diff --git
a/lib/path-concat.c
b/lib/path-concat.c
index 8c4bbb4e8b2e73c3a5b5d16df79ffea1dc1fbda2..d6dafc939850ad1467f2612f88649364313e642a 100644
(file)
--- 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;