From 8d9c181e3b9e91d68b1d6eb3ced2030c07137d82 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Jul 2022 14:28:08 +0930 Subject: [PATCH] dualopend: plug memleak. 1. fromwire now allocates TLVs, so this was actually a leak. 2. We can simply hand "NULL" to towire_, since that is the same as this empty tlv. ``` ...89221a0054c11c1e3ca31d59-dualopend-chan#1: MEMLEAK: 0x56148649c458 ...89221a0054c11c1e3ca31d59-dualopend-chan#1: label=wire/peer_exp_wiregen.c:1041:struct tlv_channel_reestablish_tlvs ...89221a0054c11c1e3ca31d59-dualopend-chan#1: backtrace: ...89221a0054c11c1e3ca31d59-dualopend-chan#1: /home/rusty/devel/cvs/lightning/ccan/ccan/tal/tal.c:442 (tal_alloc_) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: /home/rusty/devel/cvs/lightning/wire/peer_exp_wiregen.c:1041 (tlv_channel_reestablish_tlvs_new) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: /home/rusty/devel/cvs/lightning/openingd/dualopend.c:3536 (do_reconnect_dance) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: /home/rusty/devel/cvs/lightning/openingd/dualopend.c:3955 (main) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: ../csu/libc-start.c:392 (__libc_start_main_impl) ...89221a0054c11c1e3ca31d59-dualopend-chan#1: parents: ``` Signed-off-by: Rusty Russell --- openingd/dualopend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openingd/dualopend.c b/openingd/dualopend.c index e754b800f..1a418e100 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -3533,7 +3533,7 @@ static void do_reconnect_dance(struct state *state) struct pubkey remote_current_per_commit_point; struct tx_state *tx_state = state->tx_state; #if EXPERIMENTAL_FEATURES - struct tlv_channel_reestablish_tlvs *tlvs = tlv_channel_reestablish_tlvs_new(NULL); + struct tlv_channel_reestablish_tlvs *tlvs; #endif /* BOLT #2: @@ -3550,7 +3550,7 @@ static void do_reconnect_dance(struct state *state) &last_remote_per_commit_secret, &state->first_per_commitment_point[LOCAL] #if EXPERIMENTAL_FEATURES - , tlvs + , NULL #endif ); peer_write(state->pps, take(msg));