瀏覽代碼

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

Check result of IOSystem::Open before constructing stream.

Partially addresses #3888.
Jason C 4 年之前
父節點
當前提交
1cd3752ec6
共有 1 個文件被更改,包括 6 次插入1 次删除
  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];