summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-02-28 09:25:09 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-02-28 09:30:06 +0900
commit405f5a2d2ac39cfb9e294aba420fe70d87f15cb1 (patch)
tree5fa99bf7ecbc6d6b1ebce753bd88fbacf5ad4c2f /src/string.c
parent74dbee8e5275e51d92acb26bf04558d67a3edea4 (diff)
downloadmruby-405f5a2d2ac39cfb9e294aba420fe70d87f15cb1.tar.gz
mruby-405f5a2d2ac39cfb9e294aba420fe70d87f15cb1.zip
Add type check by mrb_get_args(); ref #3476
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/string.c b/src/string.c
index 84f33024e..a0d75f544 100644
--- a/src/string.c
+++ b/src/string.c
@@ -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) {