Skip to content

Commit 9411bc1

Browse files
committed
Merge pull request #26 from Shopify/fix_32_bit_uints
Fix problems with overflowing 32 bit uints
2 parents fd51825 + 74d44b5 commit 9411bc1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bit32.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
const bitCount = 32
88

99
func trim(x uint) uint { return x & math.MaxUint32 }
10-
func mask(n uint) uint { return ^((math.MaxUint32 << 1) << (n - 1)) }
10+
func mask(n uint) uint { return ^(math.MaxUint32 << n) }
1111

1212
func shift(l *State, r uint, i int) int {
1313
if i < 0 {

undump.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (state *loadState) readString() (s string, err error) {
6565
var size uintptr
6666
var size64 uint64
6767
var size32 uint32
68-
if maxUint == math.MaxUint64 {
68+
if uint64(maxUint) == math.MaxUint64 {
6969
err = state.read(&size64)
7070
size = uintptr(size64)
7171
} else if maxUint == math.MaxUint32 {

0 commit comments

Comments
 (0)