]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix json output when printing infinity values 427/head
authorJulien Thomas <jthomas@exosec.fr>
Wed, 20 Nov 2013 14:48:06 +0000 (15:48 +0100)
committerJulien Thomas <jthomas@exosec.fr>
Wed, 20 Nov 2013 16:21:17 +0000 (17:21 +0100)
The printf of a rrd_value_t variable can output inf in case of an
infinity value. That inf value is not JSON valid, nor are Infinity,
NaN, Number.NEGATIVE_INFINITY or Number.POSITIVE_INFINITY.

This commit adds a test for infinity values by using isinf() and
outputs a null in such case.

src/rrd_tool.c

index 57e22ce0d6c1278985d0e0630ca73946d3b3d39e..3002d383795bee0be8b047f37a1ad3403251fb28 100644 (file)
@@ -804,7 +804,7 @@ int HandleInputLine(
                     rrd_value_t newval = DNAN;
                     newval = *ptr;
                     if (json){
-                        if (isnan(newval)){
+                        if (isnan(newval) || isinf(newval)){
                             printf("null");                        
                         } else {
                             printf("%0.10e",newval);