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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-10-22 19:44:29 +10:30
parent 61ecc4086d
commit c821e41085
3 changed files with 4 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <ccan/list/list.h>
#include <ccan/mem/mem.h>
@@ -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");
}

View File

@@ -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,

View File

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