mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix array replace leak error in mruby-uri.
This commit is contained in:
@@ -377,6 +377,9 @@ ary_replace(mrb_state *mrb, struct RArray *a, struct RArray *b)
|
||||
if (ARY_EMBED_P(a)) {
|
||||
ARY_UNSET_EMBED_FLAG(a);
|
||||
}
|
||||
else {
|
||||
mrb_free(mrb, a->as.heap.ptr);
|
||||
}
|
||||
a->as.heap.ptr = b->as.heap.ptr;
|
||||
a->as.heap.len = len;
|
||||
a->as.heap.aux.shared = b->as.heap.aux.shared;
|
||||
|
||||
@@ -392,3 +392,10 @@ assert('Array#freeze') do
|
||||
a[0] = 1
|
||||
end
|
||||
end
|
||||
|
||||
assert('shared array replace') do
|
||||
a = [0] * 40
|
||||
b = [0, 1, 2]
|
||||
b.replace a[1, 20].dup
|
||||
assert_equal 20, b.size
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user