diff options
author | David Robillard <d@drobilla.net> | 2014-12-18 05:49:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-18 05:49:15 +0000 |
commit | b5028e368328899fee90c5d38b694ec0b86e1324 (patch) | |
tree | fc8d0e26eb4e9a0b1dbc7eb86a6f440ba6f580f5 /src/zix/btree.c | |
parent | fdf4f00e83fd3843a3fae406c24102ee667c274f (diff) | |
download | sord-b5028e368328899fee90c5d38b694ec0b86e1324.tar.gz sord-b5028e368328899fee90c5d38b694ec0b86e1324.tar.bz2 sord-b5028e368328899fee90c5d38b694ec0b86e1324.zip |
Fix unlikely tree bugs.
git-svn-id: http://svn.drobilla.net/sord/trunk@319 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src/zix/btree.c')
-rw-r--r-- | src/zix/btree.c | 9 |
1 files 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); } } |