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
42110dce
Commit
42110dce
authored
Jul 09, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2455 from cremno/readint_mrb_int-check-base
invalid base shouldn't silently fail
parents
334b1ac4
ef59f553
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
src/codegen.c
src/codegen.c
+14
-15
No files found.
src/codegen.c
View file @
42110dce
...
...
@@ -1095,6 +1095,7 @@ readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_boo
mrb_int
result
=
0
;
int
n
;
mrb_assert
(
base
>=
2
&&
base
<=
36
);
if
(
*
p
==
'+'
)
p
++
;
while
(
p
<
e
)
{
char
c
=
*
p
;
...
...
@@ -1108,23 +1109,21 @@ readint_mrb_int(codegen_scope *s, const char *p, int base, mrb_bool neg, mrb_boo
codegen_error
(
s
,
"malformed readint input"
);
}
if
(
base
>
0
)
{
if
(
neg
)
{
if
((
MRB_INT_MIN
+
n
)
/
base
>
result
)
{
*
overflow
=
TRUE
;
return
0
;
}
result
*=
base
;
result
-=
n
;
if
(
neg
)
{
if
((
MRB_INT_MIN
+
n
)
/
base
>
result
)
{
*
overflow
=
TRUE
;
return
0
;
}
else
{
if
((
MRB_INT_MAX
-
n
)
/
base
<
result
)
{
*
overflow
=
TRUE
;
return
0
;
}
result
*=
base
;
re
sult
+=
n
;
result
*=
base
;
result
-=
n
;
}
else
{
if
((
MRB_INT_MAX
-
n
)
/
base
<
result
)
{
*
overflow
=
TRUE
;
re
turn
0
;
}
result
*=
base
;
result
+=
n
;
}
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