1
0
mirror of https://github.com/golang/go synced 2024-11-06 16:36:20 -07:00

encoding/gob: increase "tooBig" from 1GB to 8GB on 64-bit machines

A little shift magic makes it easy to adjust the maximum buffer
size on machines with larger integers.

Fixes #27635

Change-Id: I1f26b07a363fbb9730df2377052475fa88bbb781
Reviewed-on: https://go-review.googlesource.com/c/143678
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Rob Pike 2018-10-22 14:17:06 +11:00
parent 7c2718b12a
commit 3bf9b77c0c

View File

@ -12,10 +12,10 @@ import (
"sync" "sync"
) )
// tooBig provides a sanity check for sizes; used in several places. // tooBig provides a sanity check for sizes; used in several places. Upper limit
// Upper limit of 1GB, allowing room to grow a little without overflow. // of is 1GB on 32-bit systems, 8GB on 64-bit, allowing room to grow a little
// TODO: make this adjustable? // without overflow.
const tooBig = 1 << 30 const tooBig = (1 << 30) << (^uint(0) >> 62)
// A Decoder manages the receipt of type and data information read from the // A Decoder manages the receipt of type and data information read from the
// remote side of a connection. // remote side of a connection.