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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-12-01 11:13:32 +09:00
parent 9f2fca6ebe
commit dbb8cf637e
+3
View File
@@ -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);