* bignum.c (rb_str_to_inum): get rid of too huge alloca().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ac0178910e
commit
5a00a61681
@ -1,3 +1,7 @@
|
|||||||
|
Thu Jan 27 21:58:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* bignum.c (rb_str_to_inum): get rid of too huge alloca().
|
||||||
|
|
||||||
Thu Jan 27 21:43:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Thu Jan 27 21:43:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
|
* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
|
||||||
|
9
bignum.c
9
bignum.c
@ -734,6 +734,8 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
|
|||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
long len;
|
long len;
|
||||||
|
VALUE v = 0;
|
||||||
|
VALUE ret;
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
if (badcheck) {
|
if (badcheck) {
|
||||||
@ -745,14 +747,17 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
|
|||||||
if (s) {
|
if (s) {
|
||||||
len = RSTRING_LEN(str);
|
len = RSTRING_LEN(str);
|
||||||
if (s[len]) { /* no sentinel somehow */
|
if (s[len]) { /* no sentinel somehow */
|
||||||
char *p = ALLOCA_N(char, len+1);
|
char *p = ALLOCV(v, len+1);
|
||||||
|
|
||||||
MEMCPY(p, s, char, len);
|
MEMCPY(p, s, char, len);
|
||||||
p[len] = '\0';
|
p[len] = '\0';
|
||||||
s = p;
|
s = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rb_cstr_to_inum(s, base, badcheck);
|
ret = rb_cstr_to_inum(s, base, badcheck);
|
||||||
|
if (v)
|
||||||
|
ALLOCV_END(v);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_LONG_LONG
|
#if HAVE_LONG_LONG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user