From 5ac34d2fc4f0249500efc5f2c443265353da63ba Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Sep 2021 00:27:39 -0400 Subject: Fix zix_btree_lower_bound() This condition was converted to an assertion in an over-eager session of code simplification and coverage testing. It turns out this does happen. --- src/btree.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/btree.c b/src/btree.c index d824c23..a73a2d0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -895,13 +895,14 @@ zix_btree_lower_bound(const ZixBTree* const t, return ZIX_STATUS_SUCCESS; } - assert(ti->indexes[ti->level] == ti->nodes[ti->level]->n_vals); - if (found) { - // Found on a previous level but went too far - ti->level = found_level; - } else { - // Reached end (key is greater than everything in tree) - *ti = zix_btree_end_iter; + if (ti->indexes[ti->level] == ti->nodes[ti->level]->n_vals) { + if (found) { + // Found on a previous level but went too far + ti->level = found_level; + } else { + // Reached end (key is greater than everything in tree) + *ti = zix_btree_end_iter; + } } return ZIX_STATUS_SUCCESS; -- cgit v1.2.1