Browse Source

Check that mMaterials not null before access (#5874)

Co-authored-by: Kim Kulling <[email protected]>
Julian Knodt 10 months ago
parent
commit
48bd7c3e22
1 changed files with 4 additions and 1 deletions
  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) {
+    static const std::string EmptyStr;
+    if ( nullptr == pScene->mMaterials ) {
+        return EmptyStr;
+    }
     const aiMaterial* const mat = pScene->mMaterials[index];
     if ( nullptr == mat ) {
-        static const std::string EmptyStr;
         return EmptyStr;
     }