Browse Source

X3D: simplistic attempt to avoid crashes due to nullptr access

Related: https://github.com/assimp/assimp/issues/4201

while the crashes go away, i'm not sure whether this is the correct fix.
also, afaict the X3D importer produces wrong results anyhow
IOhannes m zmölnig 3 years ago
parent
commit
0e2ac2a91c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      code/AssetLib/X3D/X3DImporter_Group.cpp

+ 6 - 1
code/AssetLib/X3D/X3DImporter_Group.cpp

@@ -226,8 +226,13 @@ void X3DImporter::startReadTransform(XmlNode &node) {
     // if "USE" defined then find already defined element.
     if (!use.empty()) {
         X3DNodeElementBase *ne(nullptr);
-
+        bool newgroup = (nullptr == mNodeElementCur);
+        if(newgroup)
+            ParseHelper_Group_Begin();
         ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Group, ne);
+        if (newgroup && isNodeEmpty(node)) {
+            ParseHelper_Node_Exit();
+        }
     } else {
         ParseHelper_Group_Begin(); // create new grouping element and go deeper if node has children.
         // at this place new group mode created and made current, so we can name it.