[nendo] 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:31:24 -04:00
parent 1cd3752ec6
commit e52c297284
1 changed files with 7 additions and 1 deletions

View File

@ -116,7 +116,13 @@ void NDOImporter::SetupProperties(const Importer* /*pImp*/)
void NDOImporter::InternReadFile( const std::string& pFile, void NDOImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler) aiScene* pScene, IOSystem* pIOHandler)
{ {
StreamReaderBE reader(pIOHandler->Open( pFile, "rb"));
auto file = pIOHandler->Open( pFile, "rb");
if (!file) {
throw DeadlyImportError("Nendo: Could not open ", pFile);
}
StreamReaderBE reader(file);
// first 9 bytes are nendo file format ("nendo 1.n") // first 9 bytes are nendo file format ("nendo 1.n")
const char* head = (const char*)reader.GetPtr(); const char* head = (const char*)reader.GetPtr();