rbtree: fix allocation failre paths.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 10 Jan 2011 05:55:22 +0000 (16:25 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 10 Jan 2011 05:55:22 +0000 (16:25 +1030)
ccan/rbtree/rbtree.c

index e3b4a9518fe0b64537c5933c30ab8578b10c46c8..f0a74edb6317ed0f6b02d880f81ce9f15e8b70c6 100644 (file)
@@ -671,6 +671,8 @@ trbt_insert32(trbt_tree_t *tree, uint32_t key, void *data)
                                trbt_node_t *new_node;
 
                                new_node = trbt_create_node(tree, node, key, data);
+                               if (!new_node)
+                                       return NULL;
                                node->left=new_node;
                                node=new_node;
 
@@ -685,6 +687,8 @@ trbt_insert32(trbt_tree_t *tree, uint32_t key, void *data)
                                trbt_node_t *new_node;
 
                                new_node = trbt_create_node(tree, node, key, data);
+                               if (!new_node)
+                                       return NULL;
                                node->right=new_node;
                                node=new_node;
                                break;