diff options
| author | Andrea Faulds <ajf@ajf.me> | 2016-01-08 17:20:52 +0000 |
|---|---|---|
| committer | Andrea Faulds <ajf@ajf.me> | 2016-01-08 17:20:52 +0000 |
| commit | ae50a0c0beba08e6abbc6cb5131fc44d5c6dde42 (patch) | |
| tree | a425cefd17167ae66a9a2da99d2a3e97e668db85 | |
| parent | c7256095c544b0ebc28026b277573eaa374c9c11 (diff) | |
| download | php-git-ae50a0c0beba08e6abbc6cb5131fc44d5c6dde42.tar.gz | |
Fix bug #71314
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/var_export_bug71314.phpt | 15 | ||||
| -rw-r--r-- | ext/standard/var.c | 4 |
3 files changed, 19 insertions, 1 deletions
@@ -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 0000000000..aaa8f794c0 --- /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 3b03c32ca2..61a7179dbb 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); |
