Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
e86c252a
Commit
e86c252a
authored
Aug 05, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Left shift of signed integers is undefined behavior in C; fix #3762
parent
8095754e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
22 deletions
+14
-22
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+14
-22
No files found.
mrbgems/mruby-compiler/core/parse.y
View file @
e86c252a
...
...
@@ -3768,11 +3768,11 @@ scan_oct(const int *start, int len, int *retlen)
}
static int32_t
scan_hex(const int *start, int len, int *retlen)
scan_hex(
parser_state *p,
const int *start, int len, int *retlen)
{
static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
const int *s = start;
int32_t retval = 0;
u
int32_t retval = 0;
char *tmp;
/* mrb_assert(len <= 8) */
...
...
@@ -3783,20 +3783,27 @@ scan_hex(const int *start, int len, int *retlen)
}
*retlen = s - start;
return retval;
if (retval > 0x10FFFF || (retval & 0xFFFFF800) == 0xD800) {
yyerror(p, "Invalid Unicode code point");
return -1;
}
return (int32_t)retval;
}
static int32_t
read_escape_unicode(parser_state *p, int limit)
{
int32_t c;
int buf[9];
int i;
/* Look for opening brace */
i = 0;
buf[0] = nextc(p);
if (buf[0] < 0) goto eof;
if (buf[0] < 0) {
eof:
yyerror(p, "Invalid escape character syntax");
return -1;
}
if (ISXDIGIT(buf[0])) {
/* \uxxxx form */
for (i=1; i<limit; i++) {
...
...
@@ -3811,17 +3818,7 @@ read_escape_unicode(parser_state *p, int limit)
else {
pushback(p, buf[0]);
}
c = scan_hex(buf, i, &i);
if (i == 0) {
eof:
yyerror(p, "Invalid escape character syntax");
return -1;
}
if (c < 0 || c > 0x10FFFF || (c & 0xFFFFF800) == 0xD800) {
yyerror(p, "Invalid Unicode code point");
return -1;
}
return c;
return scan_hex(p, buf, i, &i);
}
/* Return negative to indicate Unicode code point */
...
...
@@ -3887,13 +3884,8 @@ read_escape(parser_state *p)
break;
}
}
c = scan_hex(buf, i, &i);
if (i == 0) {
yyerror(p, "Invalid escape character syntax");
return 0;
return scan_hex(p, buf, i, &i);
}
}
return c;
case 'u': /* Unicode */
if (peek(p, '{')) {
...
...
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