diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-02-28 09:21:24 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-02-28 09:21:24 +0900 |
| commit | 74dbee8e5275e51d92acb26bf04558d67a3edea4 (patch) | |
| tree | e147810d9e5564d3fba6d341d4c5129cc3188cb8 | |
| parent | bdac7dfae818908f7459fc086727b717aa586c7d (diff) | |
| download | mruby-74dbee8e5275e51d92acb26bf04558d67a3edea4.tar.gz mruby-74dbee8e5275e51d92acb26bf04558d67a3edea4.zip | |
Add check before calling str_substr(); ref #3476
| -rw-r--r-- | src/string.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/string.c b/src/string.c index b5d34b8b5..84f33024e 100644 --- a/src/string.c +++ b/src/string.c @@ -1168,8 +1168,11 @@ mrb_str_aref_m(mrb_state *mrb, mrb_value str) argc = mrb_get_args(mrb, "o|o", &a1, &a2); if (argc == 2) { + mrb_int n1, n2; + mrb_regexp_check(mrb, a1); - return str_substr(mrb, str, mrb_fixnum(a1), mrb_fixnum(a2)); + mrb_get_args(mrb, "ii", &n1, &n2); + return str_substr(mrb, str, n1, n2); } if (argc != 1) { mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 1)", mrb_fixnum_value(argc)); |
