Skip to content

Commit c821e41

Browse files
committed
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 <[email protected]>
1 parent 61ecc40 commit c821e41

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

common/utils.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "config.h"
2+
#include <assert.h>
23
#include <bitcoin/chainparams.h>
34
#include <ccan/list/list.h>
45
#include <ccan/mem/mem.h>
@@ -99,6 +100,8 @@ void setup_locale(void)
99100
/* Initial creation of tmpctx. */
100101
void setup_tmpctx(void)
101102
{
103+
/* Don't call me twice! */
104+
assert(!tmpctx);
102105
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
103106
}
104107

devtools/route.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ static struct route_hop *least_cost(struct gossmap *map,
2828
struct route_hop *path;
2929
struct timemono tstart, tstop;
3030

31-
setup_locale();
32-
setup_tmpctx();
33-
3431
tstart = time_mono();
3532
dij = dijkstra(tmpctx, map, dst,
3633
sent, riskfactor, route_can_carry,

openingd/dualopend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4334,7 +4334,7 @@ static void fetch_per_commitment_point(u32 point_count,
43344334

43354335
int main(int argc, char *argv[])
43364336
{
4337-
common_setup(argv[0]);
4337+
setup_locale();
43384338

43394339
struct pollfd pollfd[2];
43404340
struct state *state = tal(NULL, struct state);

0 commit comments

Comments
 (0)