mirror of
https://gcc.gnu.org/git/gcc.git
synced 2025-01-24 21:33:53 +08:00
runtime: Reject surrogate pairs in range over string.
From-SVN: r191638
This commit is contained in:
parent
1e39ea0812
commit
a2383b317b
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user