X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Fpath%2Fpath.c;h=a0dbe291440e248fba0faddf6a70bf0062c0c009;hp=e6e94dbe080dca24fcdb5ec02a4701381029647b;hb=291237b4fed863be74051274ac5ad9920cb33cc3;hpb=15ed4f453713f1a7bdeec22b53704819fa3d447f diff --git a/ccan/tal/path/path.c b/ccan/tal/path/path.c index e6e94dbe..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);