AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 18 Bitcoin

lightningd: fix spurious memleak in peer_connected_serialize.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
lightningd: fix spurious memleak in peer_connected_serialize.

Of course stream will be freed soon, too, but if run at the exact
right time, memleak will get upset: use tmpctx.

```
lightningd: MEMLEAK: 0x5616f720bc48
lightningd: label=common/wireaddr.c:255:char[]
lightningd: alloc:
lightningd: /home/runner/work/lightning/lightning/ccan/ccan/tal/tal.c:488 (tal_alloc_)
lightningd: /home/runner/work/lightning/lightning/ccan/ccan/tal/tal.c:517 (tal_alloc_arr_)
lightningd: /home/runner/work/lightning/lightning/ccan/ccan/tal/str/str.c:81 (tal_vfmt_)
lightningd: /home/runner/work/lightning/lightning/ccan/ccan/tal/str/str.c:37 (tal_fmt_)
lightningd: /home/runner/work/lightning/lightning/common/wireaddr.c:255 (fmt_wireaddr_without_port)
lightningd: /home/runner/work/lightning/lightning/common/wireaddr.c:276 (fmt_wireaddr)
lightningd: /home/runner/work/lightning/lightning/common/wireaddr.c:232 (fmt_wireaddr_internal)
lightningd: /home/runner/work/lightning/lightning/lightningd/peer_control.c:1327 (peer_connected_serialize)
lightningd: /home/runner/work/lightning/lightning/lightningd/plugin_hook.c:359 (plugin_hook_call_next)
lightningd: /home/runner/work/lightning/lightning/lightningd/plugin_hook.c:395 (plugin_hook_call_)
lightningd: /home/runner/work/lightning/lightning/lightningd/peer_control.c:1753 (plugin_hook_call_peer_connected)
lightningd: /home/runner/work/lightning/lightning/lightningd/peer_control.c:1885 (handle_peer_connected)
lightningd: /home/runner/work/lightning/lightning/lightningd/connect_control.c:563 (connectd_msg)
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a harmless memory-accounting false alarm. A function that prepares data for a plugin hook was allocating small formatting strings under a long-lived object instead of a short-lived temporary context. Core Lightning's memory-leak detector could, in rare timing conditions, flag those strings as leaked. The fix moves the allocations to the temporary context so the detector is no longer upset. There is no user-visible bug, crash, or security vulnerability.

Recommended action

No security action required. Treat as normal code-quality/maintenance fix. If running a build that includes this path, updating removes a rare memleak warning from logs.

Security signals we found

01

memory-leak detector false positive

02

tal allocation context corrected

03

no attacker-controlled input path identified

04

no privilege boundary crossed

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 1/15
Affected reach 2/15
Confidence 9/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.