diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-09-22 07:18:45 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-09-22 07:18:45 +0000 |
commit | a2383b317b9d082d5d8d1661d61adc3d902efa83 (patch) | |
tree | 49b7fd4c0e56ed9951e50dbde6a9bf580b3a380f | |
parent | 1e39ea08122ef6db924f2ae622e03d4bedde8cd5 (diff) | |
download | gcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.zip gcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.tar.gz gcc-a2383b317b9d082d5d8d1661d61adc3d902efa83.tar.bz2 |
runtime: Reject surrogate pairs in range over string.
From-SVN: r191638
-rw-r--r-- | libgo/runtime/go-rune.c | 8 |
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; } |