diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-18 02:34:56 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-18 02:34:56 +0900 |
| commit | b2916f1b5cbebc2e7c10a757a36b6c6c4d36e583 (patch) | |
| tree | 67f547285e77b862baaf11989e631807d07d50b6 | |
| parent | 27fc76f6c63e21a83e5df306c46e694433eedd30 (diff) | |
| download | mruby-b2916f1b5cbebc2e7c10a757a36b6c6c4d36e583.tar.gz mruby-b2916f1b5cbebc2e7c10a757a36b6c6c4d36e583.zip | |
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.
| -rw-r--r-- | src/error.c | 19 | ||||
| -rw-r--r-- | src/kernel.c | 4 |
2 files changed, 7 insertions, 16 deletions
diff --git a/src/error.c b/src/error.c index 931361763..01c0e376c 100644 --- a/src/error.c +++ b/src/error.c @@ -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 @@ exception_call: 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) { diff --git a/src/kernel.c b/src/kernel.c index 3377f5a11..65d6213fa 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -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); } |
