]> granicus.if.org Git - php/commitdiff
Fix bug #71314
authorAndrea Faulds <ajf@ajf.me>
Fri, 8 Jan 2016 17:20:52 +0000 (17:20 +0000)
committerAndrea Faulds <ajf@ajf.me>
Fri, 8 Jan 2016 17:20:52 +0000 (17:20 +0000)
NEWS
ext/standard/tests/general_functions/var_export_bug71314.phpt [new file with mode: 0644]
ext/standard/var.c

diff --git a/NEWS b/NEWS
index a79cbad88a2a8015055672e3c15be23cb1be346f..ac12adf197cf6bbafadbb0ec0b0f0169d0e4e52f 100644 (file)
--- 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 (file)
index 0000000..aaa8f79
--- /dev/null
@@ -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
index 3b03c32ca24c74c1c1f1d5b25c93c98f9dfd482c..61a7179dbb308ef8020cb5137e9dfd2ca79958bc 100644 (file)
@@ -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);