瀏覽代碼

Check that mMaterials not null before access (#5874)

Co-authored-by: Kim Kulling <[email protected]>
Julian Knodt 10 月之前
父節點
當前提交
48bd7c3e22
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      code/AssetLib/Obj/ObjExporter.cpp

+ 4 - 1
code/AssetLib/Obj/ObjExporter.cpp

@@ -174,9 +174,12 @@ void ObjExporter::WriteHeader(std::ostringstream& out) {
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 std::string ObjExporter::GetMaterialName(unsigned int index) {
 std::string ObjExporter::GetMaterialName(unsigned int index) {
+    static const std::string EmptyStr;
+    if ( nullptr == pScene->mMaterials ) {
+        return EmptyStr;
+    }
     const aiMaterial* const mat = pScene->mMaterials[index];
     const aiMaterial* const mat = pScene->mMaterials[index];
     if ( nullptr == mat ) {
     if ( nullptr == mat ) {
-        static const std::string EmptyStr;
         return EmptyStr;
         return EmptyStr;
     }
     }