Backtrace list must be an array of strings; fix #3408

parent 28b7b9ec
......@@ -208,6 +208,19 @@ exc_set_backtrace(mrb_state *mrb, mrb_value exc)
mrb_value backtrace;
mrb_get_args(mrb, "o", &backtrace);
if (!mrb_array_p(backtrace)) {
type_err:
mrb_raise(mrb, E_TYPE_ERROR, "backtrace must be Array of String");
}
else {
const mrb_value *p = RARRAY_PTR(backtrace);
const mrb_value *pend = p + RARRAY_LEN(backtrace);
while (p < pend) {
if (!mrb_string_p(*p)) goto type_err;
p++;
}
}
mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "backtrace"), backtrace);
return backtrace;
......
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