From: Mark Kavanagh Date: Mon, 19 Feb 2018 16:39:31 +0000 (+0000) Subject: utils_ovs: fix potential NULL dereference X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d70f64f4c908c0016fa26c976a74511b4ac4478d;p=collectd.git utils_ovs: fix potential NULL dereference In ovs_utils_get_map_value(), YAJL_GET_ARRAY may return NULL, which is subsequently dereferenced. Ensure that the returned pointer is non-NULL before attempting to dereference it. Fixes: 12f6497 ("ovs_events: Add external ids as metadata") Signed-off-by: Mark Kavanagh --- diff --git a/src/utils_ovs.c b/src/utils_ovs.c index 088ed7db..a081fa95 100644 --- a/src/utils_ovs.c +++ b/src/utils_ovs.c @@ -1368,6 +1368,9 @@ yajl_val ovs_utils_get_map_value(yajl_val jval, const char *key) { return NULL; /* try to find map value by map key */ + if (YAJL_GET_ARRAY(array_values[1]) == NULL) + return NULL; + map_len = YAJL_GET_ARRAY(array_values[1])->len; map_values = YAJL_GET_ARRAY(array_values[1])->values; for (size_t i = 0; i < map_len; i++) {