]> granicus.if.org Git - php/commitdiff
Fix _php_math_round UB
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Jun 2019 11:18:23 +0000 (13:18 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 19 Jun 2019 13:09:00 +0000 (15:09 +0200)
php_intlog10abs() is ill-defined for a zero value. Avoid calling it
altogether as there's nothing to round with a zero value.

ext/standard/math.c

index 840df9103e631c66629914f4a0f4005a3c3da5b4..5172bbbd6e62d48ad211e4a9c45f918bf03cb483 100644 (file)
@@ -129,7 +129,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
        double tmp_value;
        int precision_places;
 
-       if (!zend_finite(value)) {
+       if (!zend_finite(value) || value == 0.0) {
                return value;
        }