Unverified Commit 1c66d42e authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4010 from take-cheeze/fix_ary_replace_leak

Fix array replace leak error in mruby-uri.
parents 8bfad558 e66c9902
......@@ -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
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