[libxml2] Remove unreachable code in xmlXPathCountFunction



commit f75256e7db7728a6f6cf519955319ed6ef7797ed
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Tue Apr 23 17:23:39 2019 +0200

    Remove unreachable code in xmlXPathCountFunction
    
    After the initial test, the condition
    
        (type == XPATH_NODESET) || (type == XPATH_XSLT_TREE)
    
    always holds true.

 xpath.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
---
diff --git a/xpath.c b/xpath.c
index d15fd8bb..30e9959a 100644
--- a/xpath.c
+++ b/xpath.c
@@ -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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]