Skip to content

Commit

Permalink
topology: fix memleak in listchannels
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
whitslack authored and rustyrussell committed Jan 3, 2023
1 parent 22eac96 commit 9d5eab1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions plugins/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9d5eab1

Please sign in to comment.