bkpr: cleanup csv_safe_str

This commit is contained in:
niftynei
2022-07-27 19:34:59 -05:00
committed by Rusty Russell
parent c83c1521ce
commit 6e9af1ef3e
2 changed files with 3 additions and 3 deletions

View File

@@ -777,7 +777,7 @@ void *tal_dup_(const tal_t *ctx, const void *p, size_t size,
(void)taken(p); (void)taken(p);
return NULL; return NULL;
} }
if (!adjust_size(&nbytes, n)) { if (!adjust_size(&nbytes, n)) {
if (taken(p)) if (taken(p))
tal_free(p); tal_free(p);

View File

@@ -115,13 +115,13 @@ static char *csv_safe_str(const tal_t *ctx, char *input TAKES)
char *dupe; char *dupe;
/* Update the double-quotes in place */ /* Update the double-quotes in place */
dupe = tal_strdup(ctx, input); dupe = tal_strdup(tmpctx, input);
for (size_t i = 0; dupe[i] != '\0'; i++) { for (size_t i = 0; dupe[i] != '\0'; i++) {
if (dupe[i] == '"') if (dupe[i] == '"')
dupe[i] = '\''; dupe[i] = '\'';
} }
esc = json_escape(ctx, dupe); esc = json_escape(tmpctx, take(dupe));
return tal_fmt(ctx, "\"%s\"", esc->s); return tal_fmt(ctx, "\"%s\"", esc->s);
} }