From b5028e368328899fee90c5d38b694ec0b86e1324 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 18 Dec 2014 05:49:15 +0000 Subject: Fix unlikely tree bugs. git-svn-id: http://svn.drobilla.net/sord/trunk@319 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/zix/btree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/zix/btree.c b/src/zix/btree.c index 82a7955..4557ad4 100644 --- a/src/zix/btree.c +++ b/src/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