summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0adbc78)
raw | patch | inline | side by side (parent: 0adbc78)
author | Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com> | |
Mon, 6 Mar 2017 16:52:10 +0000 (16:52 +0000) | ||
committer | Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com> | |
Fri, 10 Mar 2017 10:42:17 +0000 (10:42 +0000) |
src/utils_ovs.c:366:20: warning: Access to field 'type' results in a dereference of a null pointer (loaded from variable 'jval')
(int)(jval)->type);
^~~~~~~~~~~~
...
Change-Id: Ic856d21f2121f920bdd2043c69620555bb3d1cb8
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
(int)(jval)->type);
^~~~~~~~~~~~
...
Change-Id: Ic856d21f2121f920bdd2043c69620555bb3d1cb8
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
src/ovs_stats.c | patch | blob | history | |
src/utils_ovs.c | patch | blob | history |
diff --git a/src/ovs_stats.c b/src/ovs_stats.c
index 1641e87559cd2d53f011cf6a6e4c4f803ccd648f..23b7533c185a0ddeb52d21c800c5ce2351e28b78 100644 (file)
--- a/src/ovs_stats.c
+++ b/src/ovs_stats.c
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]);
@@ -557,6 +561,8 @@ static int ovs_stats_update_iface_ext_ids(port_list_t *port, yajl_val ext_ids) {
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) {
diff --git a/src/utils_ovs.c b/src/utils_ovs.c
index 57da628e33c722b416435c75d9979d16e219cf1d..65e667950a04452e9234003ba2c6bba56a88b05f 100644 (file)
--- a/src/utils_ovs.c
+++ b/src/utils_ovs.c
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)