X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Fpath%2Fpath.c;h=a0dbe291440e248fba0faddf6a70bf0062c0c009;hp=0ad168c872d219d3b485e23d53d39ab430d40eb7;hb=ba57295a55704ad68f46f7ee741dc8f3ac9db6af;hpb=892f59bdc1830443f87ad3aaeddaab2eeefb5937 diff --git a/ccan/tal/path/path.c b/ccan/tal/path/path.c index 0ad168c8..a0dbe291 100644 --- a/ccan/tal/path/path.c +++ b/ccan/tal/path/path.c @@ -244,8 +244,10 @@ char *path_rel(const tal_t *ctx, const char *from, const char *to) /* This frees to if we're supposed to take it. */ cto = path_canon(tmpctx, to); - if (!cto) + if (!cto) { + ret = NULL; goto out; + } /* How much is in common? */ for (common = i = 0; cfrom[i] && cto[i]; i++) { @@ -323,7 +325,9 @@ fail_take_to: goto fail; } - ret[len] = '\0'; + if (ret) + ret[len] = '\0'; + out: if (taken(linkname)) tal_free(linkname); @@ -525,7 +529,7 @@ bool path_is_dir(const char *path) char **path_split(const tal_t *ctx, const char *path) { bool empty = path && !path[0]; - char **ret = strsplit(ctx, path, PATH_SEP_STR, STR_NO_EMPTY); + char **ret = tal_strsplit(ctx, path, PATH_SEP_STR, STR_NO_EMPTY); /* Handle the "/" case */ if (ret && !empty && !ret[0]) {