Permalink
Browse files

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

  • Loading branch information...
matz committed Dec 1, 2015
1 parent 9f2fca6 commit dbb8cf637e8311ffa3c35829d4c007b1434fe0c6
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/string.c
View
@@ -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);

0 comments on commit dbb8cf6

Please sign in to comment.