aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-09-22 07:18:45 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-09-22 07:18:45 +0000
commita2383b317b9d082d5d8d1661d61adc3d902efa83 (patch)
tree49b7fd4c0e56ed9951e50dbde6a9bf580b3a380f /libgo
parent1e39ea08122ef6db924f2ae622e03d4bedde8cd5 (diff)
downloadgcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.zip
gcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.tar.gz
gcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.tar.bz2
runtime: Reject surrogate pairs in range over string.
From-SVN: r191638
Diffstat (limited to 'libgo')
-rw-r--r--libgo/runtime/go-rune.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libgo/runtime/go-rune.c b/libgo/runtime/go-rune.c
index 7e31eb8..acdecb0 100644
--- a/libgo/runtime/go-rune.c
+++ b/libgo/runtime/go-rune.c
@@ -53,6 +53,14 @@ __go_get_rune (const unsigned char *str, size_t len, int *rune)
*rune = (((c & 0xf) << 12)
+ ((c1 & 0x3f) << 6)
+ (c2 & 0x3f));
+
+ if (*rune >= 0xd800 && *rune < 0xe000)
+ {
+ /* Invalid surrogate half; return replace character. */
+ *rune = 0xfffd;
+ return 1;
+ }
+
return 3;
}