topology: fix memleak in listchannels

local_connected allocates a struct node_map off of the struct
listchannels_opts but fails to ever release the internal table, so those
table allocations hang around forever. Add node_map_clear as a
destructor for the struct node_map to ensure that the internal table is
freed when the enclosing struct is freed.

Changelog-Fixed: topology: Fixed memleak in `listchannels`
Signed-off-by: Matt Whitlock <c-lightning@mattwhitlock.name>
This commit is contained in:
Matt Whitlock 2023-01-01 20:53:24 -05:00 committed by Rusty Russell
parent 22eac96750
commit 9d5eab1b69

View File

@ -305,6 +305,7 @@ static struct node_map *local_connected(const tal_t *ctx,
struct node_map *connected = tal(ctx, struct node_map);
node_map_init(connected);
tal_add_destructor(connected, node_map_clear);
json_for_each_arr(i, t, peers) {
const jsmntok_t *chans, *c;