Skip to content

Commit

Permalink
AssbinImporter::ReadInternFile now closes stream before throwing (ass…
Browse files Browse the repository at this point in the history
…imp#5927)

While one of the throws in the function did indeed close the open stream,
several didn't.

Co-authored-by: Kim Kulling <[email protected]>
  • Loading branch information
david-campos and kimkulling authored Jan 3, 2025
1 parent bbeb515 commit a4d8a5f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/AssetLib/Assbin/AssbinLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I
unsigned int versionMajor = Read<unsigned int>(stream);
unsigned int versionMinor = Read<unsigned int>(stream);
if (versionMinor != ASSBIN_VERSION_MINOR || versionMajor != ASSBIN_VERSION_MAJOR) {
pIOHandler->Close(stream);
throw DeadlyImportError("Invalid version, data format not compatible!");
}

Expand All @@ -697,8 +698,10 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I
shortened = Read<uint16_t>(stream) > 0;
compressed = Read<uint16_t>(stream) > 0;

if (shortened)
if (shortened) {
pIOHandler->Close(stream);
throw DeadlyImportError("Shortened binaries are not supported!");
}

stream->Seek(256, aiOrigin_CUR); // original filename
stream->Seek(128, aiOrigin_CUR); // options
Expand Down

0 comments on commit a4d8a5f

Please sign in to comment.