lightningd: parent watchman's formatted blockhash strings to tmpctx
Some checks failed
Continuous Integration / Pre-build checks (push) Has been cancelled
Release Rust 🦀 / release_rust (push) Has been cancelled
Continuous Integration / Build compile-clang-sanitizers (push) Has been cancelled
Continuous Integration / Build compile-clang (push) Has been cancelled
Continuous Integration / Build compile-gcc (push) Has been cancelled
Continuous Integration / Build compile-gcc-O1 (push) Has been cancelled
Continuous Integration / Build compile-gcc-O3 (push) Has been cancelled
Continuous Integration / check-compiled-source (compile-gcc) (push) Has been cancelled
Continuous Integration / Run unit tests (push) Has been cancelled
Continuous Integration / Run unit tests-1 (push) Has been cancelled
Continuous Integration / Build 32-bit (size_t != 64-bit warnings) (push) Has been cancelled
Continuous Integration / Run fuzz regression tests (push) Has been cancelled
Continuous Integration / Check we can downgrade the node (push) Has been cancelled
Continuous Integration / Check we can downgrade the node-1 (push) Has been cancelled
Continuous Integration / Check we can downgrade the node-2 (push) Has been cancelled
Continuous Integration / First Integration Tests (1/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (2/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (3/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (4/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (5/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (6/6) (push) Has been cancelled
Continuous Integration / Test CLN dual-fund Full Integration (push) Has been cancelled
Continuous Integration / Test CLN liquid Full Integration (push) Has been cancelled
Continuous Integration / Test CLN postgres Full Integration (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (1/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (10/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (11/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (12/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (2/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (3/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (4/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (5/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (6/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (7/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (8/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (9/12) (push) Has been cancelled
Continuous Integration / ASan/UBSan (1/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (2/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (3/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (4/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (5/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (6/6) (push) Has been cancelled
Continuous Integration / Update examples in doc schemas (push) Has been cancelled
Continuous Integration / Test minimum supported BTC v25.0 with clang (push) Has been cancelled
Continuous Integration / CI completion (push) Has been cancelled

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
This commit is contained in:
Ken Sedgwick 2026-07-28 12:33:52 -07:00 committed by Sangbida
parent cfa9b6f92d
commit 5a56a976b4

View file

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