From fa2f988176a46dabc3adb4144a56f34f89ae6d1b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 3 Jan 2010 22:45:20 +0100 Subject: [PATCH] btr_add_output(): Fix memory leak in case node has no children. --- buffer_tree.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buffer_tree.c b/buffer_tree.c index 1a6b6e60..c826e8fa 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -119,6 +119,11 @@ void btr_add_output(char *buf, size_t size, struct btr_node *btrn) { struct btr_buffer *btrb; + assert(size != 0); + if (list_empty(&btrn->children)) { + free(buf); + return; + } btrb = new_btrb(buf, size); add_btrb_to_children(btrb, btrn, 0); } -- 2.39.5