btr_add_output(): Fix memory leak in case node has no children.
authorAndre Noll <maan@systemlinux.org>
Sun, 3 Jan 2010 21:45:20 +0000 (22:45 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 3 Jan 2010 21:45:20 +0000 (22:45 +0100)
buffer_tree.c

index 1a6b6e6..c826e8f 100644 (file)
@@ -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);
 }