Backtrace list must be an array of strings; fix
@@ -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;
