]> xenbits.xensource.com Git - xen.git/commitdiff
libxenstat: YAJL_GET_STRING may return NULL
authorWei Liu <wei.liu2@citrix.com>
Wed, 8 Apr 2015 16:08:20 +0000 (17:08 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Apr 2015 16:10:57 +0000 (17:10 +0100)
Passing NULL to strcmp can cause segmentation fault. Continue in that
case.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Charles Arnold <carnold@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstat/libxenstat/src/xenstat_qmp.c

index 10ae104ccf6a183e8aa88c69d953840d9fecdb7a..aad15c8196e2b18be706e63055fd7f2457a4dea3 100644 (file)
@@ -110,7 +110,7 @@ static char *qmp_get_block_image(xenstat_node *node, char *qmp_devname, int qfd)
                ptr[0] = qblock[QMP_BLOCK_DEVICE]; /* "device" */
                if ((dev_obj = yajl_tree_get(n, ptr, yajl_t_any)) != NULL) {
                        tmp = YAJL_GET_STRING(dev_obj);
-                       if (strcmp(qmp_devname, tmp))
+                       if (!tmp || strcmp(qmp_devname, tmp))
                                continue;
                }
                else