Skip to content

Commit

Permalink
utils: fix 32 bit system bug
Browse files Browse the repository at this point in the history
For startPositionAtRow, calculated offset variable was an int which was
being casted to uint64. This would overflow on 32bit systems and so we
make sure we always use uint64 and don't let the value be int.
  • Loading branch information
kcalvinalvin committed Apr 10, 2024
1 parent 5da0067 commit 133f222
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ func startPositionAtRow(row, forestRows uint8) uint64 {
// 2 << forestRows is 2 more than the max poisition
// to get the correct offset for a given row,
// subtract (2 << `row complement of forestRows`) from (2 << forestRows)
offset := (2 << forestRows) - (2 << (forestRows - row))
return uint64(offset)
return uint64(2<<forestRows) - (2 << (forestRows - row))
}

// maxPossiblePosAtRow returns the biggest position an accumulator can have for the
Expand Down

0 comments on commit 133f222

Please sign in to comment.