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
a4d55881
Commit
a4d55881
authored
Nov 18, 2015
by
murase_syuka
Committed by
Yukihiro "Matz" Matsumoto
Nov 18, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix lshift() bit overflow; close #3023
parent
22464fe5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
src/numeric.c
src/numeric.c
+2
-1
test/t/integer.rb
test/t/integer.rb
+3
-0
No files found.
src/numeric.c
View file @
a4d55881
...
...
@@ -821,7 +821,8 @@ static mrb_value
lshift
(
mrb_state
*
mrb
,
mrb_int
val
,
mrb_int
width
)
{
mrb_assert
(
width
>
0
);
if
(
width
>
NUMERIC_SHIFT_WIDTH_MAX
)
{
if
((
width
>
NUMERIC_SHIFT_WIDTH_MAX
)
||
(
val
>
(
MRB_INT_MAX
>>
width
)))
{
mrb_float
f
=
(
mrb_float
)
val
;
while
(
width
--
)
{
f
*=
2
;
...
...
test/t/integer.rb
View file @
a4d55881
...
...
@@ -147,6 +147,9 @@ assert('Integer#<<', '15.2.8.3.12') do
# Left Shift by a negative is Right Shift
assert_equal
23
,
46
<<
-
1
# Left Shift by 31 is bitShift overflow to SignedInt
assert_equal
2147483648
,
1
<<
31
end
assert
(
'Integer#>>'
,
'15.2.8.3.13'
)
do
...
...
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