From d43be0938c2a2fbc1499b0d0fa5e8680b2d07a19 Mon Sep 17 00:00:00 2001 From: Julien Thomas Date: Wed, 20 Nov 2013 15:48:06 +0100 Subject: [PATCH] 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. --- src/rrd_tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.47.2