Commit fd899481 authored by dearblue's avatar dearblue

Fix empty array refers; ref #4556

For example, `"".unpack("")` evaluates to `[]`.
parent 4861be11
......@@ -1299,7 +1299,12 @@ pack_unpack(mrb_state *mrb, mrb_value str, int single)
if (single) break;
}
if (single) return RARRAY_PTR(result)[0];
if (single) {
if (RARRAY_LEN(result) > 0) {
return RARRAY_PTR(result)[0];
}
return mrb_nil_value();
}
return result;
}
......
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