diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-16 06:26:33 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-16 06:26:33 +0000 |
commit | db26a9b105f0e2b4850c45554c1e77aa35973ef4 (patch) | |
tree | 33bed36b99a8590dd8868b286423a8937419679d /object.c | |
parent | 2402ecabb064525651667374a0f758321bbc7f65 (diff) | |
download | ruby-db26a9b105f0e2b4850c45554c1e77aa35973ef4.tar.gz |
* load.c (rb_feature_p): get rid of unlimited alloca.
* object.c (rb_cstr_to_dbl): ditto.
* io.c (mode_enc): fixed uninitialized variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -19,6 +19,7 @@ #include <errno.h> #include <ctype.h> #include <math.h> +#include <float.h> VALUE rb_cBasicObject; VALUE rb_mKernel; @@ -2048,15 +2049,16 @@ rb_cstr_to_dbl(const char *p, int badcheck) return d; } if (*end) { - char *buf = ALLOCA_N(char, strlen(p)+1); + char buf[DBL_DIG * 4 + 10]; char *n = buf; + char *e = buf + sizeof(buf) - 1; - while (p < end) *n++ = *p++; - while (*p) { + while (p < end && n < e) *n++ = *p++; + while (n < e && *p) { if (*p == '_') { /* remove underscores between digits */ - if (n == buf || !ISDIGIT(n[-1])) goto bad; - while (*++p == '_'); + if (n == buf || !ISDIGIT(n[-1])) goto bad; + while (*++p == '_'); if (!ISDIGIT(*p)) { if (badcheck) goto bad; break; |