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:
cataphract                               Sun, 12 Jun 2011 00:56:18 +0000

Revision: 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.c

Modified: 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 @@
     | lice...@php.net so we can mail you a copy immediately.               |
     +----------------------------------------------------------------------+
     | Authors: Jim Winstead<j...@php.net>                                  |
-   |          Stig S�ther Bakken<s...@php.net>                             |
+   |          Stig Sæther Bakken<s...@php.net>                             |
     |          Zeev Suraski<z...@zend.com>                                 |
     | PHP 4.0 patches by Thies C. Arntzen<th...@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_helper
         Actually 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 @@
     | lice...@php.net so we can mail you a copy immediately.               |
     +----------------------------------------------------------------------+
     | Authors: Jim Winstead<j...@php.net>                                  |
-   |          Stig S�ther Bakken<s...@php.net>                             |
+   |          Stig Sæther Bakken<s...@php.net>                             |
     |          Zeev Suraski<z...@zend.com>                                 |
     | PHP 4.0 patches by Thies C. Arntzen<th...@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_helper
         Actually 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 @@
     | lice...@php.net so we can mail you a copy immediately.               |
     +----------------------------------------------------------------------+
     | Authors: Jim Winstead<j...@php.net>                                  |
-   |          Stig S�ther Bakken<s...@php.net>                             |
+   |          Stig Sæther Bakken<s...@php.net>                             |
     |          Zeev Suraski<z...@zend.com>                                 |
     | PHP 4.0 patches by Thies C. Arntzen<th...@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_helper
         Actually 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));




--
Email: christopher.jo...@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to