`ary_dup()` should not use `ary_replace(); fix #4004

Otherwise the duplicated object may have shared entities that
should not be modified in-line.
parent 391e2421
...@@ -684,11 +684,7 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val) ...@@ -684,11 +684,7 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
static struct RArray* static struct RArray*
ary_dup(mrb_state *mrb, struct RArray *a) ary_dup(mrb_state *mrb, struct RArray *a)
{ {
mrb_int len = ARY_LEN(a); return ary_new_from_values(mrb, ARY_LEN(a), ARY_PTR(a));
struct RArray *d = ary_new_capa(mrb, len);
ary_replace(mrb, d, a);
return d;
} }
MRB_API mrb_value MRB_API mrb_value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment