Skip to content

Commit

Permalink
* bignum.c (rb_str_to_inum): get rid of too huge alloca().
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
kosaki committed Jan 27, 2011
1 parent ac01789 commit 5a00a61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Thu Jan 27 21:58:32 2011 KOSAKI Motohiro <[email protected]>

* bignum.c (rb_str_to_inum): get rid of too huge alloca().

Thu Jan 27 21:43:29 2011 KOSAKI Motohiro <[email protected]>

* object.c (rb_str_to_dbl): rewrite again. use ALLOCV instead
Expand Down
9 changes: 7 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
{
char *s;
long len;
VALUE v = 0;
VALUE ret;

StringValue(str);
if (badcheck) {
Expand All @@ -745,14 +747,17 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
if (s) {
len = RSTRING_LEN(str);
if (s[len]) { /* no sentinel somehow */
char *p = ALLOCA_N(char, len+1);
char *p = ALLOCV(v, len+1);

MEMCPY(p, s, char, len);
p[len] = '\0';
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
Expand Down

0 comments on commit 5a00a61

Please sign in to comment.