From b7d16aa6766ebf1bdcdbaac96e848794c3c87f89 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 16 Jan 2008 06:26:33 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@15074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index ae0cdd98b..ddf02b298 100644 --- a/object.c +++ b/object.c @@ -19,6 +19,7 @@ #include #include #include +#include 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; -- cgit