From 5646e5f74769164133f658d91bbe613003d5c6ab Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 29 Sep 2003 01:09:36 +0000 Subject: MFH: Fixed Bug #25665 (var_dump() hangs on Nan and INF). --- NEWS | 1 + main/spprintf.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c6e4ada65c..1e08a4a7b2 100644 --- 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) diff --git a/main/spprintf.c b/main/spprintf.c index 9f22880059..ee6991a3d0 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -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) -- cgit v1.2.1