Permalink
Browse files

Avoid mrb_check_string_type() in raising exception; fix #3506

The change may reduce flexibility, but I believe no one wants
that level of flexibility here.
  • Loading branch information...
matz committed Mar 17, 2017
1 parent 27fc76f commit b2916f1b5cbebc2e7c10a757a36b6c6c4d36e583
Showing with 7 additions and 16 deletions.
  1. +5 −14 src/error.c
  2. +2 −2 src/kernel.c
View
@@ -435,8 +435,8 @@ mrb_bug(mrb_state *mrb, const char *fmt, ...)
exit(EXIT_FAILURE);
}
static mrb_value
make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
MRB_API mrb_value
mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
{
mrb_value mesg;
int n;
@@ -448,12 +448,9 @@ make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
case 1:
if (mrb_nil_p(argv[0]))
break;
if (isstr) {
mesg = mrb_check_string_type(mrb, argv[0]);
if (!mrb_nil_p(mesg)) {
mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, mesg);
break;
}
if (mrb_string_p(argv[0])) {
mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, argv[0]);
break;
}
n = 0;
goto exception_call;
@@ -488,12 +485,6 @@ make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
return mesg;
}
MRB_API mrb_value
mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
{
return make_exception(mrb, argc, argv, TRUE);
}
MRB_API void
mrb_sys_fail(mrb_state *mrb, const char *mesg)
{
View
@@ -859,8 +859,8 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
mrb_raise(mrb, E_RUNTIME_ERROR, "");
break;
case 1:
a[1] = mrb_check_string_type(mrb, a[0]);
if (!mrb_nil_p(a[1])) {
if (mrb_string_p(a[0])) {
a[1] = a[0];
argc = 2;
a[0] = mrb_obj_value(E_RUNTIME_ERROR);
}

0 comments on commit b2916f1

Please sign in to comment.