mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
Consolidate virXPathNodeSet()
virXPathNodeSet() could return -1 when doing an evaluation failure due to xmlXPathEval() from libxml2 behaviour. * src/util/xml.c: make sure we always return 0 unless the returned XPath type is of the wrong type (meaning the query passed didn't evaluate to a node set and code must be fixed)
This commit is contained in:
parent
08bed02515
commit
2f4682a9f8
@ -490,11 +490,16 @@ virXPathNodeSet(virConnectPtr conn,
|
|||||||
relnode = ctxt->node;
|
relnode = ctxt->node;
|
||||||
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
|
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
|
||||||
ctxt->node = relnode;
|
ctxt->node = relnode;
|
||||||
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
|
if (obj == NULL)
|
||||||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) {
|
return(0);
|
||||||
|
if (obj->type != XPATH_NODESET) {
|
||||||
xmlXPathFreeObject(obj);
|
xmlXPathFreeObject(obj);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr < 0)) {
|
||||||
|
xmlXPathFreeObject(obj);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
ret = obj->nodesetval->nodeNr;
|
ret = obj->nodesetval->nodeNr;
|
||||||
if (list != NULL && ret) {
|
if (list != NULL && ret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user