commando: fix crash when rune is completely bogus.

The error routine returns a string literal in this case, which we can't take().

Reported-by: @jb55
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-07-21 11:19:38 +09:30
committed by neil saitug
parent 43e5ef3cc4
commit aaf743e438
2 changed files with 11 additions and 2 deletions

View File

@@ -344,10 +344,11 @@ static const char *check_rune(const tal_t *ctx,
cinfo.params = params;
cinfo.usage = NULL;
strmap_init(&cinfo.cached_params);
err = rune_test(ctx, master_rune, rune, check_condition, &cinfo);
err = rune_test(tmpctx, master_rune, rune, check_condition, &cinfo);
/* Just in case they manage to make us speak non-JSON, escape! */
if (err)
err = json_escape(ctx, take(err))->s;
err = json_escape(ctx, err)->s;
strmap_clear(&cinfo.cached_params);
/* If it succeeded, *now* we increment any associated usage counter. */