From ba57295a55704ad68f46f7ee741dc8f3ac9db6af Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 11 Jun 2013 14:40:49 +0930 Subject: [PATCH] tal/path: fix unset vars in error paths. Compiling with optimization FTW. Signed-off-by: Rusty Russell --- ccan/tal/path/path.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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); -- 2.39.2