From c821e410853fc2169e27a6d91073b8a0abcc8ade Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 22 Oct 2025 19:44:29 +1030 Subject: [PATCH] common: assert that they don't call setup_tmpctx() twice. Otherwise, leaks will occur. And fix up dualopend and devtool/route, which do this! Signed-off-by: Rusty Russell --- common/utils.c | 3 +++ devtools/route.c | 3 --- openingd/dualopend.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/utils.c b/common/utils.c index f51094f41..01047ea57 100644 --- a/common/utils.c +++ b/common/utils.c @@ -1,4 +1,5 @@ #include "config.h" +#include #include #include #include @@ -99,6 +100,8 @@ void setup_locale(void) /* Initial creation of tmpctx. */ void setup_tmpctx(void) { + /* Don't call me twice! */ + assert(!tmpctx); tmpctx = tal_arr_label(NULL, char, 0, "tmpctx"); } diff --git a/devtools/route.c b/devtools/route.c index d13e3cf9d..90a7de058 100644 --- a/devtools/route.c +++ b/devtools/route.c @@ -28,9 +28,6 @@ static struct route_hop *least_cost(struct gossmap *map, struct route_hop *path; struct timemono tstart, tstop; - setup_locale(); - setup_tmpctx(); - tstart = time_mono(); dij = dijkstra(tmpctx, map, dst, sent, riskfactor, route_can_carry, diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 9ac43d87a..159a418aa 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -4334,7 +4334,7 @@ static void fetch_per_commitment_point(u32 point_count, int main(int argc, char *argv[]) { - common_setup(argv[0]); + setup_locale(); struct pollfd pollfd[2]; struct state *state = tal(NULL, struct state);