Re: svn: /php/php-src/ branches/PHP_5_3/ext/standard/math.c branches/PHP_5_4/ext/standard/math.c trunk/ext/standard/math.c
| From: | Christopher Jones | Date: | Tue, 14 Jun 2011 20:19:28 +0000 |
| Subject: | Re: svn: /php/php-src/ branches/PHP_5_3/ext/standard/math.c branches/PHP_5_4/ext/standard/math.c trunk/ext/standard/math.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-65226@lists.php.net to get a copy of this message | ||
Gustavo,
This appears to be a user visible change in a user-sensitive area. Can you update NEWS?
Chris
On 06/11/2011 05:56 PM, Gustavo André dos Santos Lopes wrote:
-- Email: christopher.jones@oracle.com Tel: +1 650 506 8630 Blog: http://blogs.oracle.com/opal/cataphract Sun, 12 Jun 2011 00:56:18 +0000Revision: http://svn.php.net/viewvc?view=revision&revision=312074 Log: - Reverted r301991, which is a (partial) fix to bug #52550, addressing an overflow in a signed subtraction. This fixes the overflow without changing the algorithm. Bug: http://bugs.php.net/52550 (Analyzed) integer undefined behaviors executed during "make test" Changed paths:U php/php-src/branches/PHP_5_3/ext/standard/math.c U php/php-src/branches/PHP_5_4/ext/standard/math.c U php/php-src/trunk/ext/standard/math.cModified: php/php-src/branches/PHP_5_3/ext/standard/math.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/math.c 2011-06-12 00:31:13 UTC (rev 312073) +++ php/php-src/branches/PHP_5_3/ext/standard/math.c 2011-06-12 00:56:18 UTC (rev 312074) @@ -13,7 +13,7 @@| license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Jim Winstead<jimw@php.net> | - | Stig S�ther Bakken<ssb@php.net> | + | Stig Sæther Bakken<ssb@php.net> | | Zeev Suraski<zeev@zend.com> | | PHP 4.0 patches by Thies C. Arntzen<thies@thieso.net> | +----------------------------------------------------------------------+@@ -92,6 +92,18 @@ } /* }}} */ +/* {{{ php_math_is_finite */ +static inline int php_math_is_finite(double value) { +#if defined(PHP_WIN32) + return _finite(value); +#elif defined(isfinite) + return isfinite(value); +#else + return value == value&& (value == 0. || value * 2. != value); +#endif +} +/* }}} */ + /* {{{ php_round_helperActually performs the rounding of a value to integer in a certain mode */static inline double php_round_helper(double value, int mode) { @@ -129,11 +141,11 @@ double tmp_value; int precision_places; - if ((precision_places = php_intlog10abs(value))> 0) { - precision_places = 14 - php_intlog10abs(value); - } else { - precision_places = 14; + if (!php_math_is_finite(value)) { + return value; } + + precision_places = 14 - php_intlog10abs(value); f1 = php_intpow10(abs(places)); Modified: php/php-src/branches/PHP_5_4/ext/standard/math.c =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/math.c 2011-06-12 00:31:13 UTC (rev 312073) +++ php/php-src/branches/PHP_5_4/ext/standard/math.c 2011-06-12 00:56:18 UTC (rev 312074) @@ -13,7 +13,7 @@| license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Jim Winstead<jimw@php.net> | - | Stig S�ther Bakken<ssb@php.net> | + | Stig Sæther Bakken<ssb@php.net> | | Zeev Suraski<zeev@zend.com> | | PHP 4.0 patches by Thies C. Arntzen<thies@thieso.net> | +----------------------------------------------------------------------+@@ -92,6 +92,18 @@ } /* }}} */ +/* {{{ php_math_is_finite */ +static inline int php_math_is_finite(double value) { +#if defined(PHP_WIN32) + return _finite(value); +#elif defined(isfinite) + return isfinite(value); +#else + return value == value&& (value == 0. || value * 2. != value); +#endif +} +/* }}} */ + /* {{{ php_round_helperActually performs the rounding of a value to integer in a certain mode */static inline double php_round_helper(double value, int mode) { @@ -129,11 +141,11 @@ double tmp_value; int precision_places; - if ((precision_places = php_intlog10abs(value))> 0) { - precision_places = 14 - php_intlog10abs(value); - } else { - precision_places = 14; + if (!php_math_is_finite(value)) { + return value; } + + precision_places = 14 - php_intlog10abs(value); f1 = php_intpow10(abs(places)); Modified: php/php-src/trunk/ext/standard/math.c =================================================================== --- php/php-src/trunk/ext/standard/math.c 2011-06-12 00:31:13 UTC (rev 312073) +++ php/php-src/trunk/ext/standard/math.c 2011-06-12 00:56:18 UTC (rev 312074) @@ -13,7 +13,7 @@| license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Jim Winstead<jimw@php.net> | - | Stig S�ther Bakken<ssb@php.net> | + | Stig Sæther Bakken<ssb@php.net> | | Zeev Suraski<zeev@zend.com> | | PHP 4.0 patches by Thies C. Arntzen<thies@thieso.net> | +----------------------------------------------------------------------+@@ -92,6 +92,18 @@ } /* }}} */ +/* {{{ php_math_is_finite */ +static inline int php_math_is_finite(double value) { +#if defined(PHP_WIN32) + return _finite(value); +#elif defined(isfinite) + return isfinite(value); +#else + return value == value&& (value == 0. || value * 2. != value); +#endif +} +/* }}} */ + /* {{{ php_round_helperActually performs the rounding of a value to integer in a certain mode */static inline double php_round_helper(double value, int mode) { @@ -129,11 +141,11 @@ double tmp_value; int precision_places; - if ((precision_places = php_intlog10abs(value))> 0) { - precision_places = 14 - php_intlog10abs(value); - } else { - precision_places = 14; + if (!php_math_is_finite(value)) { + return value; } + + precision_places = 14 - php_intlog10abs(value); f1 = php_intpow10(abs(places));