Skip to content

Commit bd77d93

Browse files
committed
exit rebalancing if gparent does not exit
1 parent 00807e0 commit bd77d93

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jsrc/xdic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ static INLINE UI8 jtputslotso(DIC *dic,void *k,I n,void *v,I vn,J jt,UI lv,VIRT
15951595
CBYTE(parent)|=1; CBYTE(uncle)|=1; CBYTE(gparent)&=~1; // mark parent & uncle black, gparent red. This fixes snodex & parent but may leave a red vio at gparent
15961596
snodex=gparent; // the node to work on next, always red
15971597
parent=pdir[pi-3]; parentd=PDIRDIR(parent); parent=PDIRNODE(parent); // back up to parent
1598-
pi-=2; // we pop up to the grandparent
1598+
if(unlikely((pi-=2)<0))goto finput; // we pop up to the grandparent; if it does not exist, we're done, keep LSB of nodex=0 to copy key
15991599
}
16001600
// snodex is red, parent is red, grandparent & uncle are black. We can get out in 1 or 2 rotations.
16011601
if(gparentd!=parentd){

0 commit comments

Comments
 (0)