1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Close only valid handles

This commit is contained in:
ζeh Matt 2022-07-18 21:44:03 +03:00
parent 2014ea40b9
commit 3c8ef8463c
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0

View File

@ -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; }
};