Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
1e39ea08
Commit
1e39ea08
authored
Sep 22, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler, runtime: Reject surrogate pair converting int to string.
From-SVN: r191636
parent
d47cbb6d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
gcc/go/gofrontend/lex.cc
+6
-0
libgo/runtime/go-int-to-string.c
+9
-0
No files found.
gcc/go/gofrontend/lex.cc
View file @
1e39ea08
...
@@ -1312,6 +1312,12 @@ Lex::append_char(unsigned int v, bool is_character, std::string* str,
...
@@ -1312,6 +1312,12 @@ Lex::append_char(unsigned int v, bool is_character, std::string* str,
// Turn it into the "replacement character".
// Turn it into the "replacement character".
v
=
0xfffd
;
v
=
0xfffd
;
}
}
if
(
v
>=
0xd800
&&
v
<
0xe000
)
{
warning_at
(
location
,
0
,
"unicode code point 0x%x is invalid surrogate pair"
,
v
);
v
=
0xfffd
;
}
if
(
v
<=
0xffff
)
if
(
v
<=
0xffff
)
{
{
buf
[
0
]
=
0xe0
+
(
v
>>
12
);
buf
[
0
]
=
0xe0
+
(
v
>>
12
);
...
...
libgo/runtime/go-int-to-string.c
View file @
1e39ea08
...
@@ -17,6 +17,11 @@ __go_int_to_string (int v)
...
@@ -17,6 +17,11 @@ __go_int_to_string (int v)
unsigned
char
*
retdata
;
unsigned
char
*
retdata
;
struct
__go_string
ret
;
struct
__go_string
ret
;
/* A negative value is not valid UTF-8; turn it into the replacement
character. */
if
(
v
<
0
)
v
=
0xfffd
;
if
(
v
<=
0x7f
)
if
(
v
<=
0x7f
)
{
{
buf
[
0
]
=
v
;
buf
[
0
]
=
v
;
...
@@ -34,6 +39,10 @@ __go_int_to_string (int v)
...
@@ -34,6 +39,10 @@ __go_int_to_string (int v)
"replacement character". */
"replacement character". */
if
(
v
>
0x10ffff
)
if
(
v
>
0x10ffff
)
v
=
0xfffd
;
v
=
0xfffd
;
/* If the value is a surrogate pair, which is invalid in UTF-8,
turn it into the replacement character. */
if
(
v
>=
0xd800
&&
v
<
0xe000
)
v
=
0xfffd
;
if
(
v
<=
0xffff
)
if
(
v
<=
0xffff
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment