Project

General

Profile

Bug #9608 ยป 0001-avoid-large-alloca-on-Complex-Rational-calls.patch

normalperson (Eric Wong), 03/07/2014 09:56 AM

View differences:

complex.c
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
rational.c
{
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 == '_') {
......
conv:
*b = '\0';
*num = rb_cstr_to_inum(bb, 10, 0);
ALLOCV_END(tmp);
return ret;
}
    (1-1/1)