Skip to content

Commit a4d8a5f

Browse files
AssbinImporter::ReadInternFile now closes stream before throwing (assimp#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]>
1 parent bbeb515 commit a4d8a5f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

code/AssetLib/Assbin/AssbinLoader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I
688688
unsigned int versionMajor = Read<unsigned int>(stream);
689689
unsigned int versionMinor = Read<unsigned int>(stream);
690690
if (versionMinor != ASSBIN_VERSION_MINOR || versionMajor != ASSBIN_VERSION_MAJOR) {
691+
pIOHandler->Close(stream);
691692
throw DeadlyImportError("Invalid version, data format not compatible!");
692693
}
693694

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

700-
if (shortened)
701+
if (shortened) {
702+
pIOHandler->Close(stream);
701703
throw DeadlyImportError("Shortened binaries are not supported!");
704+
}
702705

703706
stream->Seek(256, aiOrigin_CUR); // original filename
704707
stream->Seek(128, aiOrigin_CUR); // options

0 commit comments

Comments
 (0)