summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-02 19:21:18 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-02 19:21:18 (GMT)
commita9befcdb08db9940b0bdde96c7447bb4730d3872 (patch)
treeddd612d4cdb16c7d253fef4b93440fa52c09181b /rational.c
parent0989529f88efc0882fd5f567350d196664bf8318 (diff)
avoid large alloca on Complex/Rational calls
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END [Bug #9608] * rational.c (read_digits): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/rational.c b/rational.c
index 60ff356..517a797 100644
--- a/rational.c
+++ b/rational.c
@@ -2136,13 +2136,14 @@ read_digits(const char **s, int strict,
{
char *b, *bb;
int us = 1, ret = 1;
+ VALUE tmp;
if (!isdecimal(**s)) {
*num = ZERO;
return 0;
}
- bb = b = ALLOCA_N(char, strlen(*s) + 1);
+ bb = b = ALLOCV_N(char, tmp, strlen(*s) + 1);
while (isdecimal(**s) || **s == '_') {
if (**s == '_') {
@@ -2169,6 +2170,7 @@ read_digits(const char **s, int strict,
conv:
*b = '\0';
*num = rb_cstr_to_inum(bb, 10, 0);
+ ALLOCV_END(tmp);
return ret;
}