Browse Source

[3ds] 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
116ebf6e10
1 changed files with 7 additions and 1 deletions
  1. 7 1
      code/AssetLib/3DS/3DSLoader.cpp

+ 7 - 1
code/AssetLib/3DS/3DSLoader.cpp

@@ -143,7 +143,13 @@ void Discreet3DSImporter::SetupProperties(const Importer * /*pImp*/) {
 // Imports the given file into the given scene structure.
 // Imports the given file into the given scene structure.
 void Discreet3DSImporter::InternReadFile(const std::string &pFile,
 void Discreet3DSImporter::InternReadFile(const std::string &pFile,
         aiScene *pScene, IOSystem *pIOHandler) {
         aiScene *pScene, IOSystem *pIOHandler) {
-    StreamReaderLE theStream(pIOHandler->Open(pFile, "rb"));
+
+    auto theFile = pIOHandler->Open(pFile, "rb");
+    if (!theFile) {
+        throw DeadlyImportError("3DS: Could not open ", pFile);
+    }
+
+    StreamReaderLE theStream(theFile);
 
 
     // We should have at least one chunk
     // We should have at least one chunk
     if (theStream.GetRemainingSize() < 16) {
     if (theStream.GetRemainingSize() < 16) {