ref: 051a5ba0a913455e2f0dc40e09aa5295be06466a
parent: 7e13013aa4033f7d76328d8b28b714c4aad00037
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 27 10:29:52 EDT 2021
scan: fix tree boundary condition
--- a/tree.c
+++ b/tree.c
@@ -1268,9 +1268,9 @@
p[0].b = b;
for(i = 0; i < s->root.ht; i++){
p[i].vi = blksearch(b, &s->kv, &v, &same);
- if(p[i].vi == -1 || (!same && b->type == Tleaf))
+ if(p[i].vi == -1 || (p[i].vi+1 < b->nval && !same && b->type == Tleaf)){
getval(b, ++p[i].vi, &v);
- if(b->type == Tpivot){
+ }else if(b->type == Tpivot){
p[i].bi = bufsearch(b, &s->kv, &m, &same);
if(p[i].bi == -1 || !same)
p[i].bi++;