From 88adbbd20e0c82ffde9f8e5fc983e1c72425b2f9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 10 Sep 2021 11:44:24 +0930 Subject: [PATCH] openingd: clean up state properly when a hook says to reject opening. This was just a minor leak, found by CI for test_openchannel_hook_chaining. We didn't call negotiation_aborted which frees various fields: negotiation_failed() does that for us. ``` MEMLEAK: 0x55b0f2d5f3c8 label=common/channel_type.c:19:struct channel_type backtrace: ccan/ccan/tal/tal.c:442 (tal_alloc_) common/channel_type.c:19 (channel_type_none) common/channel_type.c:27 (channel_type_static_remotekey) common/channel_type.c:136 (channel_type_accept) openingd/openingd.c:844 (fundee_channel) openingd/openingd.c:1240 (handle_peer_in) openingd/openingd.c:1510 (main) parents: openingd/openingd.c:1414:struct state ``` Signed-off-by: Rusty Russell --- openingd/openingd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openingd/openingd.c b/openingd/openingd.c index 2052b9e2e..ecaa02aed 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -1005,9 +1005,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) /* If they give us a reason to reject, do so. */ if (err_reason) { - u8 *errmsg = towire_errorfmt(NULL, &state->channel_id, - "%s", err_reason); - sync_crypto_write(state->pps, take(errmsg)); + negotiation_failed(state, false, "%s", err_reason); tal_free(err_reason); return NULL; }