OSDN Git Service
(root)
/
pf3gnuchains
/
gcc-fork.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
runtime: Reject surrogate pairs in range over string.
[pf3gnuchains/gcc-fork.git]
/
libgo
/
runtime
/
go-rune.c
diff --git
a/libgo/runtime/go-rune.c
b/libgo/runtime/go-rune.c
index
7e31eb8
..
acdecb0
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;
}