mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
fix leak in zend_strtod() on big doubles
add new test
This commit is contained in:
parent
3608dd4c11
commit
d43d090362
17
Zend/tests/zend_strtod.phpt
Normal file
17
Zend/tests/zend_strtod.phpt
Normal file
@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
zend_strtod() leaks on big doubles
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump("1139932690.21688500" - "1139932790.21688500");
|
||||
var_dump("1139932690000.21688500" - "331139932790.21688500");
|
||||
var_dump("339932690.21688500" - "4564645646456463461139932790.21688500");
|
||||
var_dump("123123139932690.21688500" - "11399327900000000.21688500");
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
float(-100)
|
||||
float(808792757210)
|
||||
float(-4.5646456464565E+27)
|
||||
float(-11276204760067000)
|
||||
Done
|
@ -1250,7 +1250,7 @@ zend_strtod
|
||||
_double rv, rv0;
|
||||
Long L;
|
||||
ULong y, z;
|
||||
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
|
||||
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta, *tmp;
|
||||
double result;
|
||||
|
||||
CONST char decimal_point = '.';
|
||||
@ -1776,5 +1776,21 @@ zend_strtod
|
||||
if (se)
|
||||
*se = (char *)s;
|
||||
result = sign ? -value(rv) : value(rv);
|
||||
|
||||
for (i = 0; i <= Kmax; i++) {
|
||||
Bigint **listp = &freelist[i];
|
||||
while ((tmp = *listp) != NULL) {
|
||||
*listp = tmp->next;
|
||||
free(tmp);
|
||||
}
|
||||
freelist[i] = NULL;
|
||||
}
|
||||
|
||||
while (p5s) {
|
||||
tmp = p5s;
|
||||
p5s = p5s->next;
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user