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
aa4d8e9a
Unverified
Commit
aa4d8e9a
authored
Nov 04, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid integer overflow in comparison.
parent
0113db67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+11
-1
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
aa4d8e9a
...
...
@@ -2487,8 +2487,12 @@ codegen(codegen_scope *s, node *tree, int val)
if
(
i
==
-
1
)
genop_1
(
s
,
OP_LOADI__1
,
cursp
());
else
if
(
i
>=
-
0xff
)
genop_2
(
s
,
OP_LOADINEG
,
cursp
(),
(
uint16_t
)
-
i
);
else
if
(
i
>=
-
0x8000
)
genop_2S
(
s
,
OP_LOADI16
,
cursp
(),
(
uint16_t
)
i
);
else
if
(
i
>=
-
0x80000000
)
genop_2SS
(
s
,
OP_LOADI32
,
cursp
(),
(
uint32_t
)
i
);
#ifdef MRB_INT64
else
if
(
i
>=
-
(
int32_t
)
0x80000000
)
genop_2SS
(
s
,
OP_LOADI32
,
cursp
(),
(
uint32_t
)
i
);
else
goto
lit_int
;
#else
else
genop_2SS
(
s
,
OP_LOADI32
,
cursp
(),
(
uint32_t
)
i
);
#endif
}
else
if
(
i
<
8
)
genop_1
(
s
,
OP_LOADI_0
+
(
uint8_t
)
i
,
cursp
());
else
if
(
i
<=
0xff
)
genop_2
(
s
,
OP_LOADI
,
cursp
(),
(
uint16_t
)
i
);
...
...
@@ -2497,7 +2501,9 @@ codegen(codegen_scope *s, node *tree, int val)
else
{
int
off
;
#ifdef MRB_INT64
lit_int:
#endif
off
=
new_lit
(
s
,
mrb_int_value
(
s
->
mrb
,
i
));
genop_bs
(
s
,
OP_LOADL
,
cursp
(),
off
);
}
...
...
@@ -2560,6 +2566,9 @@ codegen(codegen_scope *s, node *tree, int val)
else
if
(
i
>=
-
0x8000
)
{
genop_2S
(
s
,
OP_LOADI16
,
cursp
(),
(
uint16_t
)
i
);
}
#ifdef MRB_INT32
else
genop_2SS
(
s
,
OP_LOADI32
,
cursp
(),
(
uint32_t
)
i
);
#else
else
if
(
i
>=
-
0x80000000
)
{
genop_2SS
(
s
,
OP_LOADI32
,
cursp
(),
(
uint32_t
)
i
);
}
...
...
@@ -2567,6 +2576,7 @@ codegen(codegen_scope *s, node *tree, int val)
int
off
=
new_lit
(
s
,
mrb_int_value
(
s
->
mrb
,
i
));
genop_bs
(
s
,
OP_LOADL
,
cursp
(),
off
);
}
#endif
#ifndef MRB_NO_FLOAT
}
#endif
...
...
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