[libxml++] Node: Check for a null pointer, to fix a scan-build warning.



commit 77cc9293e7a1053b1fb1d15de22b8bc3a7fb8258
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 30 13:01:19 2012 +0200

    Node: Check for a null pointer, to fix a scan-build warning.
    
    * libxml++/nodes/node.cc: This seems unlikely.

 ChangeLog              |    6 ++++++
 libxml++/nodes/node.cc |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 10e5294..db29cb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-30  Murray Cumming  <murrayc murrayc com>
+
+	Node: Check for a null pointer, to fix a scan-build warning.
+
+	* libxml++/nodes/node.cc: This seems unlikely.
+
 2.35.2:
 
 2012-03-21  Murray Cumming  <murrayc murrayc com>
diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc
index 9555e9d..b00af2e 100644
--- a/libxml++/nodes/node.cc
+++ b/libxml++/nodes/node.cc
@@ -307,6 +307,12 @@ static NodeSet find_impl(xmlXPathContext* ctxt, const Glib::ustring& xpath)
     for (int i = 0; i != count; ++i)
     {
       xmlNode* cnode = xmlXPathNodeSetItem(nodeset, i);
+      if(!cnode)
+      {
+        std::cerr << "Node::find_impl: The xmlNode was null." << std::endl;
+        continue;
+      }
+
       if(cnode->type == XML_NAMESPACE_DECL)
       {
         //In this case we would cast it to a xmlNs*,



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