projects
/
gcc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1e39ea0
)
runtime: Reject surrogate pairs in range over string.
author
Ian Lance Taylor
<ian@gcc.gnu.org>
Sat, 22 Sep 2012 07:18:45 +0000
(07:18 +0000)
committer
Ian Lance Taylor
<ian@gcc.gnu.org>
Sat, 22 Sep 2012 07:18:45 +0000
(07:18 +0000)
From-SVN: r191638
libgo/runtime/go-rune.c
patch
|
blob
|
history
diff --git
a/libgo/runtime/go-rune.c
b/libgo/runtime/go-rune.c
index 7e31eb8d6229a371436a9aaffd3afb7e3b22ddf1..acdecb02467b7ae6c60a9ea84373f1c28cf6f306 100644
(file)
--- 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;
}