Fix array replace leak error in mruby-uri.

This commit is contained in:
Takeshi Watanabe
2018-04-25 13:27:00 +09:00
parent 8bfad558f8
commit e66c990234
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -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;
+7
View File
@@ -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