From 8f7ec42c09be00f1c9a3b6fba70a28f9c09bbd71 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 23:11:09 +0300 Subject: [PATCH] Close handle if valid for move assignment --- components/platform/file.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/platform/file.hpp b/components/platform/file.hpp index ae803edb22..8faf9c67cb 100644 --- a/components/platform/file.hpp +++ b/components/platform/file.hpp @@ -45,6 +45,8 @@ namespace Platform::File { ScopedHandle& operator=(const ScopedHandle& other) = delete; ScopedHandle& operator=(ScopedHandle&& other) noexcept { + if (mHandle != Handle::Invalid) + close(mHandle); mHandle = other.mHandle; other.mHandle = Handle::Invalid; return *this;