projects
/
collection4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/graph.c: Fix NULL-pointer dereference.
[collection4.git]
/
src
/
graph_ident.c
diff --git
a/src/graph_ident.c
b/src/graph_ident.c
index
e2d3cd6
..
cce580a
100644
(file)
--- a/
src/graph_ident.c
+++ b/
src/graph_ident.c
@@
-21,6
+21,8
@@
* Florian octo Forster <ff at octo.it>
**/
* Florian octo Forster <ff at octo.it>
**/
+#include "config.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@
-30,6
+32,7
@@
#include <limits.h> /* PATH_MAX */
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h> /* PATH_MAX */
#include <sys/types.h>
#include <sys/stat.h>
+#include <math.h>
#include "graph_ident.h"
#include "common.h"
#include "graph_ident.h"
#include "common.h"
@@
-558,17
+561,20
@@
static int ident_data_to_json__get_ident_data (
ident_data_to_json__data_t *data = user_data;
size_t i;
ident_data_to_json__data_t *data = user_data;
size_t i;
- yajl_gen_
map
_open (data->handler);
+ yajl_gen_
array
_open (data->handler);
for (i = 0; i < dp_num; i++)
{
for (i = 0; i < dp_num; i++)
{
- yajl_gen_
map
_open (data->handler);
+ yajl_gen_
array
_open (data->handler);
yajl_gen_integer (data->handler, (long) dp[i].time.tv_sec);
yajl_gen_integer (data->handler, (long) dp[i].time.tv_sec);
- yajl_gen_double (data->handler, dp[i].value);
- yajl_gen_map_close (data->handler);
+ if (isnan (dp[i].value))
+ yajl_gen_null (data->handler);
+ else
+ yajl_gen_double (data->handler, dp[i].value);
+ yajl_gen_array_close (data->handler);
}
}
- yajl_gen_
map
_close (data->handler);
+ yajl_gen_
array
_close (data->handler);
return (0);
} /* }}} int ident_data_to_json__get_ident_data */
return (0);
} /* }}} int ident_data_to_json__get_ident_data */
@@
-586,14
+592,11
@@
static int ident_data_to_json__get_ds_name (const graph_ident_t *ident, /* {{{ *
yajl_gen_string_cast (data->handler, ds_name, strlen (ds_name));
yajl_gen_string_cast (data->handler, "data", strlen ("data"));
yajl_gen_string_cast (data->handler, ds_name, strlen (ds_name));
yajl_gen_string_cast (data->handler, "data", strlen ("data"));
- yajl_gen_array_open (data->handler);
-
status = data_provider_get_ident_data (ident, ds_name,
data->begin, data->end,
ident_data_to_json__get_ident_data,
data);
status = data_provider_get_ident_data (ident, ds_name,
data->begin, data->end,
ident_data_to_json__get_ident_data,
data);
- yajl_gen_array_close (data->handler);
yajl_gen_map_close (data->handler);
return (status);
yajl_gen_map_close (data->handler);
return (status);