The operand of OP_ARYDUP may not be an array; fix #4094

This commit also fix #4096.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-08-30 00:15:16 +09:00
parent f76cc483d5
commit 2c93e4a0a8
+6 -1
View File
@@ -2618,7 +2618,12 @@ RETRY_TRY_BLOCK:
CASE(OP_ARYDUP, B) {
mrb_value ary = regs[a];
ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));
if (mrb_array_p(ary)) {
ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));
}
else {
ary = mrb_ary_new_from_values(mrb, 1, &ary);
}
regs[a] = ary;
NEXT;
}