From 7c760dafe2846c20f30ba59a2668c528480419e0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 14 Jun 2019 13:23:25 +0930 Subject: [PATCH] lightningd/chaintopology: free block map and watches on exit. Direct leak of 64 byte(s) in 1 object(s) allocated from: #0 0x7f4dc279163e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10c63e) #1 0x564ee8a24bb1 in htable_default_alloc ccan/ccan/htable/htable.c:19 #2 0x564ee8a2551b in double_table ccan/ccan/htable/htable.c:226 #3 0x564ee8a259e5 in htable_add_ ccan/ccan/htable/htable.c:331 #4 0x564ee89a5300 in block_map_add lightningd/chaintopology.h:83 #5 0x564ee89a6ece in add_tip lightningd/chaintopology.c:626 #6 0x564ee89a72c3 in have_new_block lightningd/chaintopology.c:694 #7 0x564ee89a3ab0 in process_rawblock lightningd/bitcoind.c:466 #8 0x564ee89a2fb4 in bcli_finished lightningd/bitcoind.c:214 #9 0x564ee8a284d6 in destroy_conn ccan/ccan/io/poll.c:244 #10 0x564ee8a284f6 in destroy_conn_close_fd ccan/ccan/io/poll.c:250 #11 0x564ee8a34a0d in notify ccan/ccan/tal/tal.c:235 #12 0x564ee8a34efc in del_tree ccan/ccan/tal/tal.c:397 #13 0x564ee8a35288 in tal_free ccan/ccan/tal/tal.c:481 #14 0x564ee8a26cf5 in io_close ccan/ccan/io/io.c:450 #15 0x564ee8a28c11 in io_loop ccan/ccan/io/poll.c:449 #16 0x564ee89b3c3b in io_loop_with_timers lightningd/io_loop_with_timers.c:24 #17 0x564ee89ba540 in main lightningd/lightningd.c:822 #18 0x7f4dc2143b6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a) Signed-off-by: Rusty Russell --- lightningd/chaintopology.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index c24f5d18e..e29813c5d 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -876,6 +876,11 @@ static void destroy_chain_topology(struct chain_topology *topo) while ((otx = list_pop(&topo->outgoing_txs, struct outgoing_tx, list))) tal_free(otx); + + /* htable uses malloc, so it would leak here */ + txwatch_hash_clear(&topo->txwatches); + txowatch_hash_clear(&topo->txowatches); + block_map_clear(&topo->block_map); } struct chain_topology *new_topology(struct lightningd *ld, struct log *log)