mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrb_str_to_inum(): should raise error when string contains null byte
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user