From 64809fb7305aa8a399bb0bbdfe3c783317d5dcc5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 4 Nov 2016 11:17:03 +1030 Subject: [PATCH] peer: free temporary transaction immediately Don't leave it around until connect is finished. Signed-off-by: Rusty Russell --- daemon/peer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/peer.c b/daemon/peer.c index f70005d64..a7d4d5868 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -2855,6 +2855,7 @@ static void json_connect(struct command *cmd, struct bitcoin_tx *tx; int output; size_t txhexlen; + const tal_t *tmpctx = tal_tmpctx(cmd); if (!json_get_params(buffer, params, "host", &host, @@ -2874,8 +2875,7 @@ static void json_connect(struct command *cmd, connect->input = tal(connect, struct anchor_input); txhexlen = txtok->end - txtok->start; - tx = bitcoin_tx_from_hex(connect->input, buffer + txtok->start, - txhexlen); + tx = bitcoin_tx_from_hex(tmpctx, buffer + txtok->start, txhexlen); if (!tx) { command_fail(cmd, "'%.*s' is not a valid transaction", txtok->end - txtok->start, @@ -2910,6 +2910,8 @@ static void json_connect(struct command *cmd, command_fail(cmd, "DNS failed"); return; } + + tal_free(tmpctx); } const struct json_command connect_command = {