Skip to content

plugin-bcli: allocate getutxout script hex on tmpctx instead of response - #9791

Merged
daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix/bcli-getutxout-memleak
Dec 1, 2026
Merged

daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix/bcli-getutxout-memleak

Conversation

@daywalker90

Copy link
Copy Markdown
Collaborator

json_add_string() copies its string argument into the json_stream buffer, so allocating tal_hex() on response leaves an unreferenced char[] child attached to struct json_stream that dev-memleak reports as a leak.

Add a unit test (plugins/test/run-bcli-getutxout.c) that runs getutxout() with memleak_init() and verifies captured_response has no leaked children.

Changelog-None

`json_add_string()` copies its string argument into the `json_stream`
buffer, so allocating `tal_hex()` on `response` leaves an unreferenced
`char[]` child attached to `struct json_stream` that `dev-memleak`
reports as a leak.

Add a unit test (`plugins/test/run-bcli-getutxout.c`) that runs
`getutxout()` and verifies no `char[]` child remains attached to
`captured_response`.
@daywalker90
daywalker90 force-pushed the fix/bcli-getutxout-memleak branch from 3debc54 to b01047b Compare December 1, 2026 13:33
@daywalker90
daywalker90 merged commit afd01c0 into ElementsProject:master Dec 1, 2026
46 checks passed
@nGoline nGoline mentioned this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants