summaryrefslogtreecommitdiff
path: root/main/snprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/snprintf.c')
-rw-r--r--main/snprintf.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/main/snprintf.c b/main/snprintf.c
index 8aa2d01881..b9383c57da 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -794,6 +794,23 @@ static int format_converter(register buffy * odp, const char *fmt,
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)
@@ -801,8 +818,7 @@ static int format_converter(register buffy * odp, const char *fmt,
/*
* * 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)