]> granicus.if.org Git - php/commitdiff
MFH: Fixed Bug #25665 (var_dump() hangs on Nan and INF).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 29 Sep 2003 01:09:36 +0000 (01:09 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 29 Sep 2003 01:09:36 +0000 (01:09 +0000)
NEWS
main/spprintf.c

diff --git a/NEWS b/NEWS
index c6e4ada65c4832f79bbedc8b4c537e819e5c9f76..1e08a4a7b26f3b298b8d4c08c17154131f12367b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP 4                                                                      NEWS
 - Fixed memory leak in gethostbynamel() if an error occurs. (Sara)
 - Fixed FastCGI being unable to bind to a specific IP. (Sascha)
 - Fixed bug #25671 (str_replace corrupting subarrays). (Sara)
+- Fixed Bug #25665 (var_dump() hangs on Nan and INF). (Ilia)
 - Fixed bug #25648 (xslt_set_encoding() being not detected correctly). (Jani)
 - Fixed bug #25636 (SNMP Session not closed on success). (Ilia, 
   nesslage[at]mwsc[dot]edu)
index 9f22880059bf97b88cbc72857b0f4f9340eca64e..ee6991a3d065008bc6a91259e78030f20f68ce2f 100644 (file)
@@ -473,6 +473,23 @@ static int xbuf_format_converter(register xbuffy * xbuf, const char *fmt, va_lis
 
                                case 'g':
                                case 'G':
+                                       fp_num = va_arg(ap, double);
+
+                                       if (zend_isnan(fp_num)) {
+                                               s = "NAN";
+                                               s_len = 3;
+                                               break;
+                                       } else if (zend_isinf(fp_num)) {
+                                               if (fp_num > 0) {
+                                                       s = "INF";
+                                                       s_len = 3;
+                                               } else {
+                                                       s = "-INF";
+                                                       s_len = 4;
+                                               }
+                                               break;
+                                       }
+
                                        if (adjust_precision == NO)
                                                precision = FLOAT_DIGITS;
                                        else if (precision == 0)
@@ -480,8 +497,7 @@ static int xbuf_format_converter(register xbuffy * xbuf, const char *fmt, va_lis
                                        /*
                                         * * We use &num_buf[ 1 ], so that we have room for the sign
                                         */
-                                       s = ap_php_gcvt(va_arg(ap, double), precision, &num_buf[1],
-                                                       alternate_form);
+                                       s = ap_php_gcvt(fp_num, precision, &num_buf[1], alternate_form);
                                        if (*s == '-')
                                                prefix_char = *s++;
                                        else if (print_sign)