[php-src] master: Fix GH-23662: avoid NAN warning in print_r()
| From: | Manish Kafle via Gina Peter Banyard | Date: | Sat, 19 Sep 2026 16:01:24 +0000 |
| Subject: | [php-src] master: Fix GH-23662: avoid NAN warning in print_r() | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141281@lists.php.net to get a copy of this message | ||
Author: Manish Kafle (CodedByManish)
Committer: Gina Peter Banyard (Girgias)
Date: 2026-09-19T16:59:26+01:00
Commit: https://github.com/php/php-src/commit/30920e9004be86f9cabc64e258b63c9806a878f3
Raw diff: https://github.com/php/php-src/commit/30920e9004be86f9cabc64e258b63c9806a878f3.diff
Fix GH-23662: avoid NAN warning in print_r()
Changed paths:
A Zend/tests/gh23662.phpt
M NEWS
M Zend/zend.c
Diff:
diff --git a/NEWS b/NEWS
index 98f99ad217ee..ead9e3308b9a 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PHP NEWS
. Fixed bug GH-23644 (Optimizer leaves a constant-vs-constant comparison
unfolded, crashing the VM in zval_undefined_cv). (ndossche)
. Fixed OSS-Fuzz 532353396 (assertion failure with static type). (Girgias)
+ . Fix GH-23662 (Avoid NAN warning in print_r()). (CodedByManish)
- CLI
. Fix GH-22567 (Windows ZTS CLI SAPI should refresh its TSRMLS cache during
diff --git a/Zend/tests/gh23662.phpt b/Zend/tests/gh23662.phpt
new file mode 100644
index 000000000000..426b6e2aa5d7
--- /dev/null
+++ b/Zend/tests/gh23662.phpt
@@ -0,0 +1,12 @@
+--TEST--
+GH-23662 (print_r() results in warning for NAN)
+--FILE--
+<?php
+print_r(NAN);
+print_r([NAN]);
+?>
+--EXPECT--
+NANArray
+(
+ [0] => NAN
+)
diff --git a/Zend/zend.c b/Zend/zend.c
index aa621c4daa8e..43cf8f5ccef2 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -597,6 +597,9 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
case IS_LONG:
smart_str_append_long(buf, Z_LVAL_P(expr));
break;
+ case IS_DOUBLE:
+ smart_str_append_double(buf, Z_DVAL_P(expr), EG(precision), false);
+ break;
case IS_REFERENCE:
zend_print_zval_r_to_buf(buf, Z_REFVAL_P(expr), indent);
break;