diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-02 14:44:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-05-02 14:44:25 +0100 |
commit | ee5ce1e90bca75985fac7553f091725bd06290c4 (patch) | |
tree | 5becde1a992b8806f895dc7ade12bcc741f81024 /src/controller.c | |
parent | 9afd92715f7be38bfe90ea68fdfc6b65e526f65b (diff) | |
download | rspamd-ee5ce1e90bca75985fac7553f091725bd06290c4.tar.gz rspamd-ee5ce1e90bca75985fac7553f091725bd06290c4.zip |
[Fix] Do not send NaN in json
Issue: #615
Reported by: @moisseev
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/controller.c b/src/controller.c index 542f197c3..06782e850 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1100,17 +1100,28 @@ rspamd_controller_handle_graph ( for (i = start_row, cnt = 0; cnt < rrd_result->rra_rows; cnt ++) { for (j = 0; j < rrd_result->ds_count; j++) { + gdouble yval; + data_elt = ucl_object_typed_new (UCL_OBJECT); t = ts * rrd_result->pdp_per_cdp; ucl_object_insert_key (data_elt, ucl_object_fromint (t), "x", 1, false); - ucl_object_insert_key (data_elt, - ucl_object_fromdouble (rrd_result->data[i * - rrd_result->ds_count + j]), - "y", 1, - false); + yval = rrd_result->data[i * rrd_result->ds_count + j]; + + if (!isnan (yval)) { + ucl_object_insert_key (data_elt, + ucl_object_fromdouble (yval), + "y", 1, + false); + } + else { + ucl_object_insert_key (data_elt, + ucl_object_typed_new (UCL_NULL), + "y", 1, + false); + } ucl_array_append (elt[j], data_elt); } |