From 0e2ac2a91ca39ebaef2a6055601a886c7031f381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 1 Dec 2021 12:21:29 +0100 Subject: [PATCH] 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 --- code/AssetLib/X3D/X3DImporter_Group.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/X3D/X3DImporter_Group.cpp b/code/AssetLib/X3D/X3DImporter_Group.cpp index b101aa4eb..e7a2e917e 100644 --- a/code/AssetLib/X3D/X3DImporter_Group.cpp +++ b/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.