From 3c8ef8463caa76cc8ba283bccaed41924e1722da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <3397065-ZehMatt@users.noreply.gitlab.com> Date: Mon, 18 Jul 2022 21:44:03 +0300 Subject: [PATCH] Close only valid handles --- components/platform/file.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/platform/file.hpp b/components/platform/file.hpp index 3456cdc113..bd22394197 100644 --- a/components/platform/file.hpp +++ b/components/platform/file.hpp @@ -36,7 +36,11 @@ namespace Platform::File { public: ScopedHandle() = default; ScopedHandle(Handle handle) : mHandle(handle) {} - ~ScopedHandle() { close(mHandle); } + ~ScopedHandle() + { + if(mHandle != Handle::Invalid) + close(mHandle); + } operator Handle() const { return mHandle; } };