com php-src: Fix _php_math_round UB: ext/standard/m ath.c
| From: | Nikita Popov | Date: | Wed, 19 Jun 2019 13:09:00 +0000 |
| Subject: | com php-src: Fix _php_math_round UB: ext/standard/m ath.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106897@lists.php.net to get a copy of this message | ||
Commit: 0c0659dc50dc17b267072f95c6e1ebddcc91e82d
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 19 Jun 2019 13:18:23 +0200
Parents: 317dfab81bedd918de9cf6a9b93428a0b0f86307
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0c0659dc50dc17b267072f95c6e1ebddcc91e82d
Log:
Fix _php_math_round UB
php_intlog10abs() is ill-defined for a zero value. Avoid calling it
altogether as there's nothing to round with a zero value.
Changed paths:
M ext/standard/math.c
Diff:
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 840df91..5172bbb 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -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;
}