mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Prevent accepting String value for mrb_get_args("i")
Accepting String value for mrb_get_args("i")
causes unintentional expression.
* `"str" * "3"` => `"strstrstr"`
This change prevents String->Integer conversion for mrb_get_args("i")
and fixes above problem.
See also:
https://github.com/mruby/mruby/issues/1903
This commit is contained in:
@@ -612,6 +612,9 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
|
||||
*p = (mrb_int)f;
|
||||
}
|
||||
break;
|
||||
case MRB_TT_STRING:
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "String can't be coerced into int");
|
||||
break;
|
||||
default:
|
||||
*p = mrb_fixnum(mrb_Integer(mrb, *sp));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user