diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp index 8c908be40..f80b65cd4 100644 --- a/code/AssetLib/FBX/FBXImporter.cpp +++ b/code/AssetLib/FBX/FBXImporter.cpp @@ -141,7 +141,10 @@ void FBXImporter::SetupProperties(const Importer *pImp) { // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. void FBXImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { - std::unique_ptr stream(pIOHandler->Open(pFile, "rb")); + auto streamCloser = [&](IOStream *pStream) { + pIOHandler->Close(pStream); + }; + std::unique_ptr stream(pIOHandler->Open(pFile, "rb"), streamCloser); if (!stream) { ThrowException("Could not open file for reading"); } diff --git a/code/AssetLib/Obj/ObjFileImporter.cpp b/code/AssetLib/Obj/ObjFileImporter.cpp index b6e1f9061..4fa122c45 100644 --- a/code/AssetLib/Obj/ObjFileImporter.cpp +++ b/code/AssetLib/Obj/ObjFileImporter.cpp @@ -107,7 +107,10 @@ const aiImporterDesc *ObjFileImporter::GetInfo() const { void ObjFileImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) { // Read file into memory static const std::string mode = "rb"; - std::unique_ptr fileStream(pIOHandler->Open(file, mode)); + auto streamCloser = [&](IOStream *pStream) { + pIOHandler->Close(pStream); + }; + std::unique_ptr fileStream(pIOHandler->Open(file, mode), streamCloser); if (!fileStream.get()) { throw DeadlyImportError("Failed to open file " + file + "."); }