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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-09-10 11:44:24 +09:30 committed by Christian Decker
parent acef45d02e
commit 88adbbd20e

View File

@ -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;
}