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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-10-13 15:44:53 +10:30
committed by neil saitug
parent 150598e061
commit 034ed1711c

View File

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