Add check to avoid crash when the API is misused.
authorCarl Hetherington <cth@carlh.net>
Sun, 2 Jul 2023 19:55:47 +0000 (21:55 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 2 Jul 2023 19:55:47 +0000 (21:55 +0200)
src/cxml.cc

index e4435a2142d83a056ebfd2e2cef6dd0d5112379a..c2d85347d2a90cd893dc483439520b4826168989 100644 (file)
@@ -98,6 +98,10 @@ cxml::Node::node_children (string name) const
           how get_path works.
        */
 
+       if (!_node) {
+               throw cxml::Error("Node has no internal xmlpp node; did you forget to call a read method on cxml::Document?");
+       }
+
        vector<shared_ptr<cxml::Node>> n;
        for (auto i: _node->get_children()) {
                if (i->get_name() == name) {