From: Julien Thomas Date: Wed, 20 Nov 2013 14:48:06 +0000 (+0100) Subject: Fix json output when printing infinity values X-Git-Tag: v1.4.9~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d43be0938c2a2fbc1499b0d0fa5e8680b2d07a19;p=thirdparty%2Frrdtool-1.x.git Fix json output when printing infinity values 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. --- diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 57e22ce0..3002d383 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -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);