From 034ed1711c4c026f82acc5ff3bb1821176f62417 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 13 Oct 2019 15:44:53 +1030 Subject: [PATCH] gossipd: fix memleak when we getnodes has no nodes. In this case, node_arr is NULL. Triggered by the next test. Signed-off-by: Rusty Russell --- gossipd/gossipd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 020ce1089..2aefcb57e 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1126,7 +1126,7 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon, } /* FIXME: towire wants array of pointers. */ - nodes = tal_arr(node_arr, const struct gossip_getnodes_entry *, + nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, tal_count(node_arr)); for (size_t i = 0; i < tal_count(node_arr); i++) nodes[i] = &node_arr[i];