浏览代码

Fix possible nullptr dereferences.

Kim Kulling 4 年之前
父节点
当前提交
88ccfedd10
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      include/assimp/XmlParser.h

+ 6 - 0
include/assimp/XmlParser.h

@@ -183,12 +183,18 @@ public:
     /// @brief  Will return the root node, const version.
     /// @brief  Will return the root node, const version.
     /// @return The root node.
     /// @return The root node.
     const TNodeType getRootNode() const {
     const TNodeType getRootNode() const {
+        if (nullptr == mDoc) {
+            return nullptr;
+        }
         return mDoc->root();
         return mDoc->root();
     }
     }
 
 
     /// @brief  Will return the root node, non-const version.
     /// @brief  Will return the root node, non-const version.
     /// @return The root node.
     /// @return The root node.
     TNodeType getRootNode() {
     TNodeType getRootNode() {
+        if (nullptr == mDoc) {
+            return nullptr;
+        }
         return mDoc->root();
         return mDoc->root();
     }
     }