summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-17 07:27:00 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-17 07:27:00 +0000
commit66d1582c07db57b4a1a1cd0ab7d79f042be80faa (patch)
treea63241e4140156b843a981d9e626356e51905210 /object.c
parente6c0ea3e097fb5b23e6ec3e909474063eba21306 (diff)
* 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 'object.c')
-rw-r--r--object.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/object.c b/object.c
index 72805e9..f505854 100644
--- a/object.c
+++ b/object.c
@@ -1031,6 +1031,7 @@ rb_cstr_to_dbl(p, badcheck)
char *end;
double d;
+ if (!p) return 0.0;
q = p;
if (badcheck) {
while (ISSPACE(*p)) p++;
@@ -1093,15 +1094,17 @@ rb_str_to_dbl(str, badcheck)
StringValue(str);
s = RSTRING(str)->ptr;
len = RSTRING(str)->len;
- if (s[len]) { /* no sentinel somehow */
- char *p = ALLOCA_N(char, len+1);
+ if (s) {
+ 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 Float contains null byte");
+ MEMCPY(p, s, char, len);
+ p[len] = '\0';
+ s = p;
+ }
+ if (badcheck && len != strlen(s)) {
+ rb_raise(rb_eArgError, "string for Float contains null byte");
+ }
}
return rb_cstr_to_dbl(s, badcheck);
}