Skip to content

Commit

Permalink
mrb_str_to_inum(): should raise error when string contains null byte
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 1, 2015
1 parent 9f2fca6 commit dbb8cf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dbb8cf6

Please sign in to comment.