aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-03-31 02:04:12 -0700
committerMatthew Dempsky <mdempsky@google.com>2016-03-31 10:28:23 +0000
commite6066711a0f92824ded94849e4f1085c2ba612c3 (patch)
treefd3692ad25b1caf5c3674c9927d30e4e011c977c /src/runtime/string.go
parente7538df7011e3767e9350655ea51edb894d61423 (diff)
downloadgo-e6066711a0f92824ded94849e4f1085c2ba612c3.tar.gz
go-e6066711a0f92824ded94849e4f1085c2ba612c3.zip
cmd/compile, runtime: fix pedantic int->string conversions
Previously, cmd/compile rejected constant int->string conversions if the integer value did not fit into an "int" value. Also, runtime incorrectly truncated 64-bit values to 32-bit before checking if they're a valid Unicode code point. According to the Go spec, both of these cases should instead yield "\uFFFD". Fixes #15039. Change-Id: I3c8a3ad9a0780c0a8dc1911386a523800fec9764 Reviewed-on: https://go-review.googlesource.com/21344 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r--src/runtime/string.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go
index 3e49b9431e..2d20e0a9c3 100644
--- a/src/runtime/string.go
+++ b/src/runtime/string.go
@@ -236,6 +236,9 @@ func intstring(buf *[4]byte, v int64) string {
} else {
s, b = rawstring(4)
}
+ if int64(rune(v)) != v {
+ v = runeerror
+ }
n := runetochar(b, rune(v))
return s[:n]
}