It seems most sensible to make it a noop, but it definitely shouldn't
access out of bounds as it does.
Reported-by: Russ Dill
Fixes: #61
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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);
{
char *path, *ctx = tal_strdup(NULL, "ctx");
- plan_tests(34);
+ plan_tests(36);
path = path_join(ctx, "foo", "bar");
ok1(streq(path, "foo/bar"));
ok1(!path);
ok1(!tal_first(ctx));
+ path = path_join(ctx, "", "bar");
+ ok1(streq(path, "bar"));
+ ok1(tal_parent(path) == ctx);
+ tal_free(path);
+
tal_free(ctx);
return exit_status();