From e2698c5fc3098e3db3e70ce46664a4a07d695a32 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 30 Nov 2021 13:36:05 +1030 Subject: [PATCH] lightningd: fix leak report for self_id This has been here for a while: self_id hangs around while we're calling the hook, but now it triggers sometimes. ``` E ValueError: E Node errors: E Global errors: E - Node /tmp/ltests-3mcyp67u/test_dev_rawrequest_1/lightning-1/ has memory leaks: [ E { E "backtrace": [ E "ccan/ccan/tal/tal.c:442 (tal_alloc_)", E "gossipd/gossipd_wiregen.c:528 (fromwire_gossipd_got_onionmsg_to_us)", E "lightningd/onion_message.c:152 (handle_onionmsg_to_us)", E "lightningd/gossip_control.c:137 (gossip_msg)", E "lightningd/subd.c:548 (sd_msg_read)", E "ccan/ccan/io/io.c:59 (next_plan)", E "ccan/ccan/io/io.c:407 (do_plan)", E "ccan/ccan/io/io.c:417 (io_ready)", E "ccan/ccan/io/poll.c:453 (io_loop)", E "lightningd/io_loop_with_timers.c:21 (io_loop_with_timers)", E "lightningd/lightningd.c:1164 (main)" E ], E "label": "gossipd/gossipd_wiregen.c:528:struct secret", E "parents": [ E "lightningd/onion_message.c:149:struct onion_message_hook_payload", E "lightningd/plugin_hook.c:81:struct hook_instance *[]" E ], E "value": "0x55cf3cbc9458" E } E ] ``` --- lightningd/onion_message.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lightningd/onion_message.c b/lightningd/onion_message.c index 9fcf475c5..88034edc8 100644 --- a/lightningd/onion_message.c +++ b/lightningd/onion_message.c @@ -173,6 +173,7 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg) * means we created the path it's using. */ if (!self_id || !secret_eq_consttime(self_id, &ld->onion_reply_secret)) payload->our_alias = tal_free(payload->our_alias); + tal_free(self_id); submsglen = tal_bytelen(submsg); subptr = submsg;