goto out;
len = strlen(base);
- ret = tal_dup(ctx, char, base, len, 1 + strlen(a) + 1);
+ ret = tal_dup_arr(ctx, char, base, len, 1 + strlen(a) + 1);
if (!ret)
goto out;
if (ret[len-1] != PATH_SEP)
/* 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++) {
goto fail;
}
- ret[len] = '\0';
+ if (ret)
+ ret[len] = '\0';
+
out:
if (taken(linkname))
tal_free(linkname);
static char *fixed_string(const tal_t *ctx,
const char *str, const char *path)
{
- char *ret = tal_dup(ctx, char, path, 0, strlen(str)+1);
+ char *ret = tal_dup_arr(ctx, char, path, 0, strlen(str)+1);
if (ret)
strcpy(ret, str);
return ret;