From 0682ad9c4890264ef80f9c6e9509a572a828a047 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 21 May 2021 14:50:05 +0930 Subject: [PATCH] fetchinvoice: don't produce invalid JSON on sent_inv timeout. An unrelated bug in the reverse path triggered this code, and boom. Signed-off-by: Rusty Russell --- plugins/fetchinvoice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c index 598aab0a3..1ba20561b 100644 --- a/plugins/fetchinvoice.c +++ b/plugins/fetchinvoice.c @@ -645,7 +645,10 @@ static void timeout_sent_inv(struct sent *sent) { struct json_out *details = json_out_new(sent); + json_out_start(details, NULL, '{'); json_out_addstr(details, "invstring", invoice_encode(tmpctx, sent->inv)); + json_out_end(details, '}'); + /* This will free sent! */ discard_result(command_done_err(sent->cmd, OFFER_TIMEOUT, "Failed: timeout waiting for response",