瀏覽代碼

Add null check for aiNode in AddNode method (#6348)

- Added null check for node in AddNode function.
- closes https://github.com/assimp/assimp/issues/6347
Kim Kulling 1 周之前
父節點
當前提交
72b9939b9f
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      code/AssetLib/Obj/ObjExporter.cpp

+ 5 - 3
code/AssetLib/Obj/ObjExporter.cpp

@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
 
 
 Copyright (c) 2006-2025, assimp team
 Copyright (c) 2006-2025, assimp team
 
 
-
 All rights reserved.
 All rights reserved.
 
 
 Redistribution and use of this software in source and binary forms,
 Redistribution and use of this software in source and binary forms,
@@ -396,9 +395,12 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent, bool merge_identical_vertices) {
 void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent, bool merge_identical_vertices) {
+    if (nd == nullptr) {
+        return;
+    }
+    
     const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
     const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
-
-    aiMesh *cm( nullptr );
+    aiMesh *cm{nullptr};
     for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
     for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
         cm = pScene->mMeshes[nd->mMeshes[i]];
         cm = pScene->mMeshes[nd->mMeshes[i]];
         if (nullptr != cm) {
         if (nullptr != cm) {