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           ]

```
This commit is contained in:
Rusty Russell 2021-11-30 13:36:05 +10:30
parent 132ac0b1b4
commit e2698c5fc3
1 changed files with 1 additions and 0 deletions

View File

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