if (br_ports && YAJL_IS_ARRAY(br_ports)) {
char *tmp = YAJL_GET_STRING(br_ports->u.array.values[0]);
if (tmp != NULL && strcmp("set", tmp) == 0) {
- yajl_val *ports_arr =
- YAJL_GET_ARRAY(br_ports->u.array.values[1])->values;
- size_t ports_num = YAJL_GET_ARRAY(br_ports->u.array.values[1])->len;
-
- for (size_t i = 0; i < ports_num; i++)
- ovs_stats_new_port(
- br, YAJL_GET_STRING(ports_arr[i]->u.array.values[1]));
+ yajl_val *array = YAJL_GET_ARRAY(br_ports)->values;
+ size_t array_len = YAJL_GET_ARRAY(br_ports)->len;
+ if (array != NULL && array_len > 0 && YAJL_IS_ARRAY(array[1])) {
+ yajl_val *ports_arr = YAJL_GET_ARRAY(array[1])->values;
+ size_t ports_num = YAJL_GET_ARRAY(array[1])->len;
+ for (size_t i = 0; i < ports_num && ports_arr != NULL; i++)
+ ovs_stats_new_port(
+ br, YAJL_GET_STRING(ports_arr[i]->u.array.values[1]));
+ }
} else
ovs_stats_new_port(br, YAJL_GET_STRING(br_ports->u.array.values[1]));
}
if (stats && YAJL_IS_ARRAY(stats))
for (size_t i = 0; i < YAJL_GET_ARRAY(stats)->len; i++) {
stat = YAJL_GET_ARRAY(stats)->values[i];
+ if (!YAJL_IS_ARRAY(stat))
+ return (-1);
counter_name = YAJL_GET_STRING(YAJL_GET_ARRAY(stat)->values[0]);
counter_index = ovs_stats_counter_name_to_type(counter_name);
counter_value = YAJL_GET_INTEGER(YAJL_GET_ARRAY(stat)->values[1]);
if (ext_ids && YAJL_IS_ARRAY(ext_ids))
for (size_t i = 0; i < YAJL_GET_ARRAY(ext_ids)->len; i++) {
ext_id = YAJL_GET_ARRAY(ext_ids)->values[i];
+ if (!YAJL_IS_ARRAY(ext_id))
+ return (-1);
key = YAJL_GET_STRING(YAJL_GET_ARRAY(ext_id)->values[0]);
value = YAJL_GET_STRING(YAJL_GET_ARRAY(ext_id)->values[1]);
if (key && value) {
size_t obj_len = 0;
yajl_gen_status yajl_gen_ret = yajl_gen_status_ok;
+ if (jval == NULL)
+ return yajl_gen_generation_complete;
+
if (YAJL_IS_STRING(jval))
OVS_YAJL_CALL(ovs_yajl_gen_tstring, jgen, YAJL_GET_STRING(jval));
else if (YAJL_IS_DOUBLE(jval))
/* get method name */
if ((jval = yajl_tree_get(jnode, method_path, yajl_t_string)) != NULL) {
- method = YAJL_GET_STRING(jval);
+ if ((method = YAJL_GET_STRING(jval)) == NULL) {
+ yajl_tree_free(jnode);
+ sfree(sjson);
+ return (-1);
+ }
if (strcmp("echo", method) == 0) {
/* echo request from the server */
if (ovs_db_table_echo_cb(pdb, jnode) < 0)