[xmlsec] fix problem with libxml2 returning NULL from xpath



commit d081286fdaf5718eab01013a47fc76539925397d
Author: Aleksey Sanin <aleksey aleksey com>
Date:   Thu Nov 3 13:55:04 2011 -0700

    fix problem with libxml2 returning NULL from xpath

 src/xpath.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/xpath.c b/src/xpath.c
index afa7c52..e67631e 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -281,6 +281,23 @@ xmlSecXPathDataExecute(xmlSecXPathDataPtr data, xmlDocPtr doc, xmlNodePtr hereNo
         break;
     }
 
+    /* sometime LibXML2 returns an empty nodeset or just NULL, we want
+    to reserve NULL for our own purposes so we simply create an empty
+    node set here */
+    if(xpathObj->nodesetval == NULL) {
+	xpathObj->nodesetval = xmlXPathNodeSetCreate(NULL);
+	if(xpathObj->nodesetval == NULL) {
+		xmlXPathFreeObject(xpathObj);
+		xmlSecError(XMLSEC_ERRORS_HERE,
+			NULL,
+                        "xmlXPathNodeSetCreate",
+                        XMLSEC_ERRORS_R_XML_FAILED,
+                        "expr=%s",
+                        xmlSecErrorsSafeString(data->expr));
+            	return(NULL);
+	}
+    }
+
     nodes = xmlSecNodeSetCreate(doc, xpathObj->nodesetval, data->nodeSetType);
     if(nodes == NULL) {
         xmlSecError(XMLSEC_ERRORS_HERE,



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