diff --git a/src/util/xml.c b/src/util/xml.c index 4118d2a..4fa443d 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -490,11 +490,16 @@ virXPathNodeSet(virConnectPtr conn, relnode = ctxt->node; obj = xmlXPathEval(BAD_CAST xpath, ctxt); ctxt->node = relnode; - if ((obj == NULL) || (obj->type != XPATH_NODESET) || - (obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) { + if (obj == NULL) + return(0); + if (obj->type != XPATH_NODESET) { xmlXPathFreeObject(obj); return (-1); } + if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) { + xmlXPathFreeObject(obj); + return (0); + } ret = obj->nodesetval->nodeNr; if (list != NULL && ret) {