summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bignum.c b/bignum.c
index 9839f552fb..a908a5c78a 100644
--- a/bignum.c
+++ b/bignum.c
@@ -507,7 +507,12 @@ rb_str_to_inum(str, base, badcheck)
long len;
StringValue(str);
- s = RSTRING(str)->ptr;
+ if (badcheck) {
+ s = StringValueCStr(str);
+ }
+ else {
+ s = RSTRING(str)->ptr;
+ }
if (s) {
len = RSTRING(str)->len;
if (s[len]) { /* no sentinel somehow */
@@ -517,9 +522,6 @@ rb_str_to_inum(str, base, badcheck)
p[len] = '\0';
s = p;
}
- if (badcheck && len != strlen(s)) {
- rb_raise(rb_eArgError, "string for Integer contains null byte");
- }
}
return rb_cstr_to_inum(s, base, badcheck);
}