[3ds] Fix assertion failure when file could not be opened

Check result of IOSystem::Open before constructing stream.

Partially addresses #3888.
pull/3890/head
Jason C 2021-05-05 17:30:05 -04:00
parent 785cca1bb4
commit 116ebf6e10
1 changed files with 7 additions and 1 deletions

View File

@ -143,7 +143,13 @@ void Discreet3DSImporter::SetupProperties(const Importer * /*pImp*/) {
// Imports the given file into the given scene structure.
void Discreet3DSImporter::InternReadFile(const std::string &pFile,
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
if (theStream.GetRemainingSize() < 16) {