com php-src: Fix bug #71314: NEWS ext/standard/tests/general_ functions/var_export_bug71314.phpt ext/standa rd/var.c
| From: | Andrea Faulds | Date: | Fri, 08 Jan 2016 17:20:52 +0000 |
| Subject: | com php-src: Fix bug #71314: NEWS ext/standard/tests/general_ functions/var_export_bug71314.phpt ext/standa rd/var.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90583@lists.php.net to get a copy of this message | ||
Commit: ae50a0c0beba08e6abbc6cb5131fc44d5c6dde42
Author: Andrea Faulds <ajf@ajf.me> Fri, 8 Jan 2016 17:20:52 +0000
Parents: c7256095c544b0ebc28026b277573eaa374c9c11
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ae50a0c0beba08e6abbc6cb5131fc44d5c6dde42
Log:
Fix bug #71314
Bugs:
https://bugs.php..net/71314
Changed paths:
M NEWS
A ext/standard/tests/general_functions/var_export_bug71314.phpt
M ext/standard/var.c
Diff:
diff --git a/NEWS b/NEWS
index a79cbad..ac12adf 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP NEWS
. Fixed bug #71273 (A wrong ext directory setup in php.ini leads to crash).
(Anatol)
. Fixed bug #71297 (Memory leak with consecutive yield from). (Bob)
+ . Fixed bug #71314 (var_export(INF) prints INF.0). (Andrea)
- CURL:
. Fixed bug #71227 (Can't compile php_curl statically). (Anatol)
diff --git a/ext/standard/tests/general_functions/var_export_bug71314.phpt
b/ext/standard/tests/general_functions/var_export_bug71314.phpt
new file mode 100644
index 0000000..aaa8f79
--- /dev/null
+++ b/ext/standard/tests/general_functions/var_export_bug71314.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #71314 (var_export(INF) prints INF.0)
+--FILE--
+<?php
+
+var_export(INF);
+echo PHP_EOL;
+var_export(-INF);
+echo PHP_EOL;
+var_export(NAN);
+echo PHP_EOL;
+--EXPECT--
+INF
+-INF
+NAN
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 3b03c32..61a7179 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -463,8 +463,10 @@ again:
/* Without a decimal point, PHP treats a number literal as an int.
* This check even works for scientific notation, because the
* mantissa always contains a decimal point.
+ * We need to check for finiteness, because INF, -INF and NAN
+ * must not have a decimal point added.
*/
- if (NULL == strchr(tmp_str, '.')) {
+ if (zend_finite(Z_DVAL_P(struc)) && NULL == strchr(tmp_str, '.')) {
smart_str_appendl(buf, ".0", 2);
}
efree(tmp_str);