[sib] 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:32:10 -04:00
parent a80b3b25eb
commit 0d3e8b52be
1 changed files with 6 additions and 1 deletions

View File

@ -804,7 +804,12 @@ static void ReadScene(SIB *sib, StreamReaderLE *stream) {
// Imports the given file into the given scene structure. // Imports the given file into the given scene structure.
void SIBImporter::InternReadFile(const std::string &pFile, void SIBImporter::InternReadFile(const std::string &pFile,
aiScene *pScene, IOSystem *pIOHandler) { aiScene *pScene, IOSystem *pIOHandler) {
StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));
auto file = pIOHandler->Open(pFile, "rb");
if (!file)
throw DeadlyImportError("SIB: Could not open ", pFile);
StreamReaderLE stream(file);
// We should have at least one chunk // We should have at least one chunk
if (stream.GetRemainingSize() < 16) if (stream.GetRemainingSize() < 16)