cvs: ZendEngine2 / zend_strtod.c /tests zend_strtod.phpt

From: Date: Tue, 14 Feb 2006 22:11:37 +0000
Subject: cvs: ZendEngine2 / zend_strtod.c /tests zend_strtod.phpt
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4582@lists.php.net to get a copy of this message
tony2001 Tue Feb 14 22:11:37 2006 UTC Modified files: /ZendEngine2/tests zend_strtod.phpt /ZendEngine2 zend_strtod.c Log: MF51: fix leak in zend_strtod() on big doubles add new test http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/zend_strtod.phpt?r1=1.1&r2=1.2&diff_format=u Index: ZendEngine2/tests/zend_strtod.phpt diff -u /dev/null ZendEngine2/tests/zend_strtod.phpt:1.2 --- /dev/null Tue Feb 14 22:11:37 2006 +++ ZendEngine2/tests/zend_strtod.phpt Tue Feb 14 22:11:36 2006 @@ -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 http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_strtod.c?r1=1.18&r2=1.19&diff_format=u Index: ZendEngine2/zend_strtod.c diff -u ZendEngine2/zend_strtod.c:1.18 ZendEngine2/zend_strtod.c:1.19 --- ZendEngine2/zend_strtod.c:1.18 Thu Aug 11 23:34:59 2005 +++ ZendEngine2/zend_strtod.c Tue Feb 14 22:11:36 2006 @@ -1252,7 +1252,7 @@ _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 = '.'; @@ -1778,6 +1778,22 @@ 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; }

« previous php.zend-engine.cvs (#4582) next »