Commit 496c710a authored by nikandfor's avatar nikandfor

Fix slice out of bounds crash

There was crash when we try insert element to full data struct at position i=0
when left neighbour data struct was not full
parent b96e30f1
...@@ -451,9 +451,14 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{ ...@@ -451,9 +451,14 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{
l, r := p.siblings(pi) l, r := p.siblings(pi)
if l != nil && l.c < 2*kd { if l != nil && l.c < 2*kd {
l.mvL(q, 1) if i > 0 {
t.insert(q, i-1, k, v) l.mvL(q, 1)
p.x[pi-1].k = q.d[0].k t.insert(q, i-1, k, v)
p.x[pi-1].k = q.d[0].k
return
}
t.insert(l, l.c, k, v)
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment