[*] NT File Stream: unlikely race condition

This commit is contained in:
Reece Wilson 2023-08-15 14:48:54 +01:00
parent 3df8621944
commit 78634d11db

View File

@ -392,15 +392,15 @@ namespace Aurora::IO::FS
HANDLE WinFileStream::GetWin32Handle(bool bReadOnly)
{
if (this->pHandle_)
if (auto pHandle = this->pHandle_)
{
if (bReadOnly)
{
return (HANDLE)this->pHandle_->GetOSReadHandleSafe().ValueOr((AuUInt)INVALID_HANDLE_VALUE);
return (HANDLE)pHandle->GetOSReadHandleSafe().ValueOr((AuUInt)INVALID_HANDLE_VALUE);
}
else
{
return (HANDLE)this->pHandle_->GetOSWriteHandleSafe().ValueOr(this->pHandle_->GetOSReadHandleSafe().ValueOr((AuUInt)INVALID_HANDLE_VALUE));
return (HANDLE)pHandle->GetOSWriteHandleSafe().ValueOr(pHandle->GetOSReadHandleSafe().ValueOr((AuUInt)INVALID_HANDLE_VALUE));
}
}