Permalink
Browse files

Add type check by mrb_get_args(); ref #3476

  • Loading branch information...
matz committed Feb 28, 2017
1 parent 74dbee8 commit 405f5a2d2ac39cfb9e294aba420fe70d87f15cb1
Showing with 2 additions and 6 deletions.
  1. +2 −6 src/string.c
View
@@ -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) {

0 comments on commit 405f5a2

Please sign in to comment.