lightningd: fix valgrind reported leak when we exit early.

```
E           Global errors:
E            - Node /tmp/ltests-adkwu44c/test_logging_1/lightning-2/ has memory leaks: [
E               {
E                   "backtrace": [
E                       "ccan/ccan/tal/tal.c:442 (tal_alloc_)",
E                       "lightningd/peer_control.c:2203 (load_channels_from_wallet)",
E                       "lightningd/lightningd.c:1105 (main)"
E                   ],
E                   "label": "lightningd/peer_control.c:2203:struct htlc_in_map",
E                   "parents": [
E                       "lightningd/lightningd.c:107:struct lightningd"
E                   ],
E                   "value": "0x55d920a345e8"
E               }
E           ]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-01-17 11:17:12 +10:30
parent 288f5df8d1
commit 8d825ef0b7
3 changed files with 6 additions and 3 deletions

View File

@@ -1117,8 +1117,11 @@ int main(int argc, char *argv[])
/*~ Now that the rpc path exists, we can start the plugins and they
* can start talking to us. */
if (!plugins_config(ld->plugins))
if (!plugins_config(ld->plugins)) {
/* Valgrind can complain about this leak! */
tal_free(unconnected_htlcs_in);
goto stop;
}
/*~ Process any HTLCs we were in the middle of when we exited, now
* that plugins (who might want to know via htlc_accepted hook) are

View File

@@ -2797,7 +2797,7 @@ void fixup_htlcs_out(struct lightningd *ld)
#endif /* COMPAT_V061 */
void htlcs_resubmit(struct lightningd *ld,
struct htlc_in_map *unconnected_htlcs_in)
struct htlc_in_map *unconnected_htlcs_in STEALS)
{
struct htlc_in *hin;
struct htlc_in_map_iter ini;

View File

@@ -65,7 +65,7 @@ void htlcs_notify_new_block(struct lightningd *ld, u32 height);
void fixup_htlcs_out(struct lightningd *ld);
void htlcs_resubmit(struct lightningd *ld,
struct htlc_in_map *unconnected_htlcs_in);
struct htlc_in_map *unconnected_htlcs_in STEALS);
/* For HTLCs which terminate here, invoice payment calls one of these. */
void fulfill_htlc(struct htlc_in *hin, const struct preimage *preimage);