summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index 510bd4e73..6c1988e92 100644
--- a/src/string.c
+++ b/src/string.c
@@ -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);