mrb_str_to_inum(): should raise error when string contains null byte

parent 9f2fca6e
......@@ -2201,6 +2201,9 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck)
s = mrb_string_value_ptr(mrb, str);
if (s) {
len = RSTRING_LEN(str);
if (badcheck && strlen(s) != len) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
}
if (s[len]) { /* no sentinel somehow */
struct RString *temp_str = str_new(mrb, s, len);
s = RSTR_PTR(temp_str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment