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
9d84f0d4
Commit
9d84f0d4
authored
Dec 31, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ary_expand_capa(): size calculation by size_t; fix #3353
Also more size checks added.
parent
270ea41b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/array.c
src/array.c
+8
-6
No files found.
src/array.c
View file @
9d84f0d4
...
...
@@ -165,9 +165,9 @@ ary_make_shared(mrb_state *mrb, struct RArray *a)
}
static
void
ary_expand_capa
(
mrb_state
*
mrb
,
struct
RArray
*
a
,
mrb_in
t
len
)
ary_expand_capa
(
mrb_state
*
mrb
,
struct
RArray
*
a
,
size_
t
len
)
{
mrb_in
t
capa
=
a
->
aux
.
capa
;
size_
t
capa
=
a
->
aux
.
capa
;
if
(
len
>
ARY_MAX_SIZE
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
...
...
@@ -177,14 +177,16 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
capa
=
ARY_DEFAULT_LEN
;
}
while
(
capa
<
len
)
{
if
(
capa
<=
ARY_MAX_SIZE
/
2
)
{
capa
*=
2
;
}
else
{
if
(
capa
>
ARY_MAX_SIZE
)
{
capa
=
ARY_MAX_SIZE
;
}
}
if
(
capa
<
len
||
capa
>
MRB_INT_MAX
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"array size too big"
);
}
if
(
capa
>
a
->
aux
.
capa
)
{
if
(
capa
>
(
size_t
)
a
->
aux
.
capa
)
{
mrb_value
*
expanded_ptr
=
(
mrb_value
*
)
mrb_realloc
(
mrb
,
a
->
ptr
,
sizeof
(
mrb_value
)
*
capa
);
a
->
aux
.
capa
=
capa
;
...
...
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