From 1eb2c124a0d2df8a9c5bb3f30457fae1e16686ec Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 2 Feb 2023 20:52:40 +0100 Subject: [PATCH] Fix: Close leak. - closes https://github.com/assimp/assimp/issues/3416 --- include/assimp/MemoryIOWrapper.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h index 0bd3bc108..fce683773 100644 --- a/include/assimp/MemoryIOWrapper.h +++ b/include/assimp/MemoryIOWrapper.h @@ -2,8 +2,7 @@ Open Asset Import Library (assimp) ---------------------------------------------------------------------- -Copyright (c) 2006-2022, assimp team - +Copyright (c) 2006-2023, assimp team All rights reserved. @@ -66,11 +65,7 @@ namespace Assimp { // ---------------------------------------------------------------------------------- class MemoryIOStream : public IOStream { public: - MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) - : buffer (buff) - , length(len) - , pos((size_t)0) - , own(own) { + MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) : buffer (buff), length(len), pos((size_t)0), own(own) { // empty } @@ -162,7 +157,11 @@ public: } /** Destructor. */ - ~MemoryIOSystem() = default; + ~MemoryIOSystem() { + for (auto &it : created_streams) { + MemoryIOSystem::Close(it); + } + } // ------------------------------------------------------------------- /** Tests for the existence of a file at the given path. */