aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Martin <ality@pbrane.org>2010-09-06 08:04:53 +1000
committerRob Pike <r@golang.org>2010-09-06 08:04:53 +1000
commit68cce4ab206586267fcfa9ac4ef3dc8396054e94 (patch)
tree833965b66d7277368ecbfa5417f0078ff35c5390
parentd54b921c9baf19105d074896da98d6dbf3c9e219 (diff)
downloadgo-68cce4ab206586267fcfa9ac4ef3dc8396054e94.tar.gz
go-68cce4ab206586267fcfa9ac4ef3dc8396054e94.zip
fmt.Scan: fix integer overflow on 32-bit machines
R=r, rsc CC=golang-dev https://golang.org/cl/2144043
-rw-r--r--src/pkg/fmt/scan.go2
-rw-r--r--src/pkg/fmt/scan_test.go3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/pkg/fmt/scan.go b/src/pkg/fmt/scan.go
index afbbeb3948..bd8af50069 100644
--- a/src/pkg/fmt/scan.go
+++ b/src/pkg/fmt/scan.go
@@ -740,7 +740,7 @@ func (s *ss) scanOne(verb int, field interface{}) {
case *int32:
*v = int32(s.scanInt(verb, 32))
case *int64:
- *v = s.scanInt(verb, intBits)
+ *v = s.scanInt(verb, 64)
case *uint:
*v = uint(s.scanUint(verb, intBits))
case *uint8:
diff --git a/src/pkg/fmt/scan_test.go b/src/pkg/fmt/scan_test.go
index 9092789897..569d2f55f3 100644
--- a/src/pkg/fmt/scan_test.go
+++ b/src/pkg/fmt/scan_test.go
@@ -183,6 +183,9 @@ var scanTests = []ScanTest{
// Custom scanner.
ScanTest{" vvv ", &xVal, Xs("vvv")},
+
+ // Fixed bugs
+ ScanTest{"2147483648\n", &int64Val, int64(2147483648)}, // was: integer overflow
}
var scanfTests = []ScanfTest{