Add type check by mrb_get_args(); ref
@@ -1591,8 +1591,7 @@ mrb_str_index(mrb_state *mrb, mrb_value str)
mrb_get_args(mrb, "*", &argv, &argc);
if (argc == 2) {
- pos = mrb_fixnum(argv[1]);
- sub = argv[0];
+ mrb_get_args(mrb, "oi", &sub, &pos);
}
else {
pos = 0;
@@ -1857,14 +1856,11 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
mrb_value *argv;
mrb_int argc;
mrb_value sub;
- mrb_value vpos;
mrb_int pos, len = RSTRING_CHAR_LEN(str);
mrb_get_args(mrb, "*", &argv, &argc);
if (argc == 2) {
- sub = argv[0];
- vpos = argv[1];
- pos = mrb_fixnum(vpos);
+ mrb_get_args(mrb, "oi", &sub, &pos);
if (pos < 0) {
pos += len;
if (pos < 0) {
