1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

Remove unreachable code in xmlXPathCountFunction

After the initial test, the condition

    (type == XPATH_NODESET) || (type == XPATH_XSLT_TREE)

always holds true.
This commit is contained in:
Nick Wellnhofer 2019-04-23 17:23:39 +02:00
parent 949eced484
commit f75256e7db

21
xpath.c
View File

@ -8508,28 +8508,9 @@ xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if ((cur == NULL) || (cur->nodesetval == NULL))
valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
else if ((cur->type == XPATH_NODESET) || (cur->type == XPATH_XSLT_TREE)) {
else
valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
(double) cur->nodesetval->nodeNr));
} else {
if ((cur->nodesetval->nodeNr != 1) ||
(cur->nodesetval->nodeTab == NULL)) {
valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
} else {
xmlNodePtr tmp;
int i = 0;
tmp = cur->nodesetval->nodeTab[0];
if ((tmp != NULL) && (tmp->type != XML_NAMESPACE_DECL)) {
tmp = tmp->children;
while (tmp != NULL) {
tmp = tmp->next;
i++;
}
}
valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));
}
}
xmlXPathReleaseObject(ctxt->context, cur);
}