]> granicus.if.org Git - icinga2/commitdiff
Fix JSON output for non-finite numbers.
authorGunnar Beutner <gunnar@beutner.name>
Tue, 15 Apr 2014 10:21:40 +0000 (12:21 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 15 Apr 2014 10:21:54 +0000 (12:21 +0200)
Fixes #6015

third-party/cJSON/cJSON.c

index 523d4f1e100e1c7f908839a5454878c5dc3ecfaf..75a1527a663934cfc45216579972ca34c4273603 100644 (file)
@@ -130,7 +130,8 @@ static char *print_number(cJSON *item)
                str=(char*)cJSON_malloc(64);    /* This is a nice tradeoff. */
                if (str)
                {
-                       if (fabs(floor(d)-d)<=DBL_EPSILON)                      sprintf(str,"%.0f",d);
+                       if (d != d)                                             strcpy(str, "0");
+                       else if (fabs(floor(d)-d)<=DBL_EPSILON)                 sprintf(str,"%.0f",d);
                        else                                                    sprintf(str,"%.*e",(int)log10(d) + 6,d);
                }
        }