From 59d83f1e9e54068eb0a16a69888530a53db28fb3 Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Tue, 28 Jul 2026 12:33:52 -0700 Subject: [PATCH] lightningd: parent watchman's formatted blockhash strings to tmpctx json_add_string copies its value, so the strings fmt_bitcoin_blkid allocates in json_block_processed and json_getwatchmanheight are referenced by nothing once the call returns. They are parented to the response stream and freed with it, but the memleak scanner works by searching memory for pointers to each allocation: when a dev memleak check races an in-flight response, the unreferenced string is reported as a leak and fails the test run (seen in a liquid CI run of test_bwatch_add_watch_creates_datastore_entry). Parent them to tmpctx, the idiom used elsewhere. Fixes: #9362 Changelog-None --- lightningd/watchman.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightningd/watchman.c b/lightningd/watchman.c index 15dd6b326094..e03b235136b1 100644 --- a/lightningd/watchman.c +++ b/lightningd/watchman.c @@ -755,7 +755,7 @@ static struct command_result *json_block_processed(struct command *cmd, json_add_u32(response, "blockheight", *blockheight); if (wm->last_processed_height > 0) json_add_string(response, "blockhash", - fmt_bitcoin_blkid(response, &wm->last_processed_hash)); + fmt_bitcoin_blkid(tmpctx, &wm->last_processed_hash)); return command_success(cmd, response); } @@ -789,7 +789,7 @@ static struct command_result *json_getwatchmanheight(struct command *cmd, json_add_u32(response, "height", height); if (wm && wm->last_processed_height > 0) json_add_string(response, "blockhash", - fmt_bitcoin_blkid(response, &wm->last_processed_hash)); + fmt_bitcoin_blkid(tmpctx, &wm->last_processed_hash)); return command_success(cmd, response); }