]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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 1a6b6e60d3f977d2d99f600d7a872a1b95250312..c826e8fa26a97c9036595ddf188bb984a7b4ec4e 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);
 }