fmt.Scan: fix integer overflow on 32-bit machines
R=r, rsc
CC=golang-dev
https://golang.org/cl/2144043
diff --git a/src/pkg/fmt/scan.go b/src/pkg/fmt/scan.go
index afbbeb3..bd8af50 100644
--- a/src/pkg/fmt/scan.go
+++ b/src/pkg/fmt/scan.go
@@ -740,7 +740,7 @@
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 9092789..569d2f5 100644
--- a/src/pkg/fmt/scan_test.go
+++ b/src/pkg/fmt/scan_test.go
@@ -183,6 +183,9 @@
// Custom scanner.
ScanTest{" vvv ", &xVal, Xs("vvv")},
+
+ // Fixed bugs
+ ScanTest{"2147483648\n", &int64Val, int64(2147483648)}, // was: integer overflow
}
var scanfTests = []ScanfTest{