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
cf5ca036
Commit
cf5ca036
authored
Feb 19, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mruby-struct: copied Struct length is not initialized; fix #3114
parent
819c9da8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
mrbgems/mruby-struct/src/struct.c
mrbgems/mruby-struct/src/struct.c
+1
-8
mrbgems/mruby-struct/test/struct.rb
mrbgems/mruby-struct/test/struct.rb
+8
-0
No files found.
mrbgems/mruby-struct/src/struct.c
View file @
cf5ca036
...
@@ -418,7 +418,6 @@ static mrb_value
...
@@ -418,7 +418,6 @@ static mrb_value
mrb_struct_init_copy
(
mrb_state
*
mrb
,
mrb_value
copy
)
mrb_struct_init_copy
(
mrb_state
*
mrb
,
mrb_value
copy
)
{
{
mrb_value
s
;
mrb_value
s
;
mrb_int
i
,
len
;
mrb_get_args
(
mrb
,
"o"
,
&
s
);
mrb_get_args
(
mrb
,
"o"
,
&
s
);
...
@@ -429,13 +428,7 @@ mrb_struct_init_copy(mrb_state *mrb, mrb_value copy)
...
@@ -429,13 +428,7 @@ mrb_struct_init_copy(mrb_state *mrb, mrb_value copy)
if
(
!
mrb_array_p
(
s
))
{
if
(
!
mrb_array_p
(
s
))
{
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"corrupted struct"
);
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"corrupted struct"
);
}
}
if
(
RSTRUCT_LEN
(
copy
)
!=
RSTRUCT_LEN
(
s
))
{
mrb_ary_replace
(
mrb
,
copy
,
s
);
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"struct size mismatch"
);
}
len
=
RSTRUCT_LEN
(
copy
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
mrb_ary_set
(
mrb
,
copy
,
i
,
RSTRUCT_PTR
(
s
)[
i
]);
}
return
copy
;
return
copy
;
}
}
...
...
mrbgems/mruby-struct/test/struct.rb
View file @
cf5ca036
...
@@ -111,6 +111,14 @@ assert('wrong struct arg count') do
...
@@ -111,6 +111,14 @@ assert('wrong struct arg count') do
end
end
end
end
assert
(
'struct dup'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
,
:m3
,
:m4
,
:m5
)
cc
=
c
.
new
(
1
,
2
,
3
,
4
,
5
)
assert_nothing_raised
{
assert_equal
(
cc
,
cc
.
dup
)
}
end
assert
(
'struct inspect'
)
do
assert
(
'struct inspect'
)
do
c
=
Struct
.
new
(
:m1
,
:m2
,
:m3
,
:m4
,
:m5
)
c
=
Struct
.
new
(
:m1
,
:m2
,
:m3
,
:m4
,
:m5
)
cc
=
c
.
new
(
1
,
2
,
3
,
4
,
5
)
cc
=
c
.
new
(
1
,
2
,
3
,
4
,
5
)
...
...
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