diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-17 07:27:00 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-17 07:27:00 +0000 |
commit | 66d1582c07db57b4a1a1cd0ab7d79f042be80faa (patch) | |
tree | a63241e4140156b843a981d9e626356e51905210 /bignum.c | |
parent | e6c0ea3e097fb5b23e6ec3e909474063eba21306 (diff) | |
download | ruby-66d1582c07db57b4a1a1cd0ab7d79f042be80faa.tar.gz |
* object.c (rb_str_to_dbl): RString ptr might be NULL.
* object.c (rb_cstr_to_dbl): p pointer might be NULL.
* bignum.c (rb_str_to_inum): RString ptr might be NULL.
* bignum.c (rb_cstr_to_inum): str pointer might be NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -319,6 +319,10 @@ rb_cstr_to_inum(str, base, badcheck) VALUE z; BDIGIT *zds; + if (!str) { + if (badcheck) goto bad; + return INT2FIX(0); + } if (badcheck) { while (ISSPACE(*str)) str++; } @@ -501,16 +505,18 @@ rb_str_to_inum(str, base, badcheck) StringValue(str); s = RSTRING(str)->ptr; - len = RSTRING(str)->len; - if (s[len]) { /* no sentinel somehow */ - char *p = ALLOCA_N(char, len+1); - - MEMCPY(p, s, char, len); - p[len] = '\0'; - s = p; - } - if (badcheck && len != strlen(s)) { - rb_raise(rb_eArgError, "string for Integer contains null byte"); + if (s) { + len = RSTRING(str)->len; + if (s[len]) { /* no sentinel somehow */ + char *p = ALLOCA_N(char, len+1); + + MEMCPY(p, s, char, len); + 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); } |