Browse Source

[ms3d] Fix assertion failure when file could not be opened.

Check result of IOSystem::Open before constructing stream.

Partially addresses #3888.
Jason C 4 years ago
parent
commit
1cd3752ec6
1 changed files with 6 additions and 1 deletions
  1. 6 1
      code/AssetLib/MS3D/MS3DLoader.cpp

+ 6 - 1
code/AssetLib/MS3D/MS3DLoader.cpp

@@ -215,7 +215,12 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints, ai
 void MS3DImporter::InternReadFile( const std::string& pFile,
     aiScene* pScene, IOSystem* pIOHandler)
 {
-    StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
+
+    auto file = pIOHandler->Open(pFile, "rb");
+    if (!file)
+        throw DeadlyImportError("MS3D: Could not open ", pFile);
+
+    StreamReaderLE stream(file);
 
     // CanRead() should have done this already
     char head[10];