diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-02 19:21:18 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-02 19:21:18 +0000 |
commit | a9befcdb08db9940b0bdde96c7447bb4730d3872 (patch) | |
tree | ddd612d4cdb16c7d253fef4b93440fa52c09181b /complex.c | |
parent | 0989529f88efc0882fd5f567350d196664bf8318 (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 'complex.c')
-rw-r--r-- | complex.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -1726,19 +1726,26 @@ parse_comp(const char *s, int strict, VALUE *num) { char *buf, *b; + VALUE tmp; + int ret = 1; - buf = ALLOCA_N(char, strlen(s) + 1); + buf = ALLOCV_N(char, tmp, strlen(s) + 1); b = buf; skip_ws(&s); - if (!read_comp(&s, strict, num, &b)) - return 0; - skip_ws(&s); + if (!read_comp(&s, strict, num, &b)) { + ret = 0; + } + else { + skip_ws(&s); - if (strict) - if (*s != '\0') - return 0; - return 1; + if (strict) + if (*s != '\0') + ret = 0; + } + ALLOCV_END(tmp); + + return ret; } static VALUE |