提交 2f4682a9 编写于 作者: D Daniel Veillard

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)
上级 08bed025
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册