runtime: Reject surrogate pairs in range over string.

From-SVN: r191639
This commit is contained in:
Ian Lance Taylor 2012-09-22 07:19:09 +00:00
parent 3fe3530d07
commit 2a12271b4e
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}