]> git.ozlabs.org Git - ccan/blobdiff - ccan/tal/path/path.c
tal/path: handle weird case of path_join("")
[ccan] / ccan / tal / path / path.c
index 93362c754f599981014916a71482b6997c98686d..c7a134e3c9d9981699f9c95e4ad10fde71b9fa7d 100644 (file)
@@ -1,7 +1,6 @@
 /* Licensed under BSD-MIT - see LICENSE file for details */
 #include <ccan/tal/path/path.h>
 #include <ccan/str/str.h>
-#include <ccan/take/take.h>
 #include <ccan/tal/str/str.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -53,7 +52,7 @@ char *path_join(const tal_t *ctx, const char *base, const char *a)
        ret = tal_dup_arr(ctx, char, base, len, 1 + strlen(a) + 1);
        if (!ret)
                goto out;
-       if (ret[len-1] != PATH_SEP)
+       if (len != 0 && ret[len-1] != PATH_SEP)
                ret[len++] = PATH_SEP;
        strcpy(ret + len, a);