Skip to content

Commit f0f8af2

Browse files
committed
fixed panic in ShiftRight when zeroing pages for the happy case
1 parent 938c2a4 commit f0f8af2

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

bitset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ func (b *BitSet) ShiftRight(bits uint) {
15551555
}
15561556
}
15571557

1558-
for i := int(idx-pages) + 1; i <= int(idx); i++ {
1558+
for i := int(idx-pages) + 1; i < len(b.set); i++ {
15591559
b.set[i] = 0
15601560
}
15611561
}

bitset_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,9 @@ func TestShiftRightFull(t *testing.T) {
24482448
{
24492449
[]uint{0, 20, 40, 1260, 1280}, 1281,
24502450
},
2451+
{
2452+
[]uint{961}, 64,
2453+
},
24512454
}
24522455

24532456
test := func(data []uint, shiftDistance uint) {

0 commit comments

Comments
 (0)