Skip to content

Commit fdfaaa8

Browse files
committed
Fix memory allocator issue.
Windows and unix allocators would panic when asked to allocate the maximum size.
1 parent 6a2827f commit fdfaaa8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/alloc/alloc_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type mmappedMemory struct {
3939
func (m *mmappedMemory) Reallocate(size uint64) []byte {
4040
com := uint64(len(m.buf))
4141
res := uint64(cap(m.buf))
42-
if com < size && size < res {
42+
if com < size && size <= res {
4343
// Round up to the page size.
4444
rnd := uint64(unix.Getpagesize() - 1)
4545
new := (size + rnd) &^ rnd

internal/alloc/alloc_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type virtualMemory struct {
4848
func (m *virtualMemory) Reallocate(size uint64) []byte {
4949
com := uint64(len(m.buf))
5050
res := uint64(cap(m.buf))
51-
if com < size && size < res {
51+
if com < size && size <= res {
5252
// Round up to the page size.
5353
rnd := uint64(windows.Getpagesize() - 1)
5454
new := (size + rnd) &^ rnd

0 commit comments

Comments
 (0)