From a4d8a5fec3fc42b17c6411b68035017c7d797298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Campos=20Rodr=C3=ADguez?= Date: Fri, 3 Jan 2025 13:38:27 -0700 Subject: [PATCH] AssbinImporter::ReadInternFile now closes stream before throwing (#5927) While one of the throws in the function did indeed close the open stream, several didn't. Co-authored-by: Kim Kulling --- code/AssetLib/Assbin/AssbinLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/Assbin/AssbinLoader.cpp b/code/AssetLib/Assbin/AssbinLoader.cpp index 70e8a06c29..45d2823c3e 100644 --- a/code/AssetLib/Assbin/AssbinLoader.cpp +++ b/code/AssetLib/Assbin/AssbinLoader.cpp @@ -688,6 +688,7 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I unsigned int versionMajor = Read(stream); unsigned int versionMinor = Read(stream); if (versionMinor != ASSBIN_VERSION_MINOR || versionMajor != ASSBIN_VERSION_MAJOR) { + pIOHandler->Close(stream); throw DeadlyImportError("Invalid version, data format not compatible!"); } @@ -697,8 +698,10 @@ void AssbinImporter::InternReadFile(const std::string &pFile, aiScene *pScene, I shortened = Read(stream) > 0; compressed = Read(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