From: Andre Noll Date: Sun, 3 Jan 2010 21:45:20 +0000 (+0100) Subject: btr_add_output(): Fix memory leak in case node has no children. X-Git-Tag: v0.4.2~208 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=fa2f988176a46dabc3adb4144a56f34f89ae6d1b;p=paraslash.git btr_add_output(): Fix memory leak in case node has no children. --- 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); }