From f683a30a854af0d24c37ecba4ed848d29bf5a4ea Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Dec 2014 05:50:08 +0000 Subject: Fix unlikely tree bugs. git-svn-id: http://svn.drobilla.net/zix/trunk@98 df6676b4-ccc9-40e5-b5d6-7c4628a128e3 --- zix/btree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'zix/btree.c') diff --git a/zix/btree.c b/zix/btree.c index 82a7955..4557ad4 100644 --- a/zix/btree.c +++ b/zix/btree.c @@ -306,12 +306,11 @@ zix_btree_insert(ZixBTree* const t, void* const e) n = n->children[i]; } else { // Insert into internal node - zix_btree_ainsert(n->vals, n->n_vals, i, e); + zix_btree_ainsert(n->vals, n->n_vals++, i, e); break; } } - ++n->n_vals; ++t->size; return ZIX_STATUS_SUCCESS; @@ -609,6 +608,11 @@ zix_btree_lower_bound(const ZixBTree* const t, const void* const e, ZixBTreeIter** const ti) { + if (!t) { + *ti = NULL; + return ZIX_STATUS_BAD_ARG; + } + ZixBTreeNode* n = t->root; bool found = false; unsigned found_level = 0; @@ -632,6 +636,7 @@ zix_btree_lower_bound(const ZixBTree* const t, } else { ++(*ti)->level; n = n->children[i]; + assert(n); } } -- cgit v1.2.1