diff options
| author | Jim Meyering <jim@meyering.net> | 2000-06-21 12:56:33 +0000 |
|---|---|---|
| committer | Jim Meyering <jim@meyering.net> | 2000-06-21 12:56:33 +0000 |
| commit | bb6ebcc3338c7c1fc3485fb048c50d6fc991642b (patch) | |
| tree | afe1111504cadf9107107b70cc439bb604e58b79 /lib/path-concat.c | |
| parent | include getstr.h (diff) | |
| download | coreutils-bb6ebcc3338c7c1fc3485fb048c50d6fc991642b.tar.gz coreutils-bb6ebcc3338c7c1fc3485fb048c50d6fc991642b.zip | |
(path_concat): Don't access dir[-1] if dir is the empty string.
Diffstat (limited to 'lib/path-concat.c')
| -rw-r--r-- | lib/path-concat.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/path-concat.c b/lib/path-concat.c index 8c4bbb4e8..d6dafc939 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; |
