[*] Found some missing close handles in some error paths
This commit is contained in:
parent
4240966512
commit
61df62213f
@ -109,31 +109,33 @@ namespace Aurora::Process
|
||||
auto offset = static_cast<AuUInt32>(reinterpret_cast<const AuUInt8 *>(nt) - reinterpret_cast<const AuUInt8 *>(mod));
|
||||
using Value_t = AuRemovePointer_t<decltype(nt)>;
|
||||
Value_t value {};
|
||||
DWORD dwBytesRead {};
|
||||
|
||||
auto handle = CreateFileW(Locale::ConvertFromUTF8(path).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
auto hHandle = CreateFileW(Locale::ConvertFromUTF8(path).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
||||
if (hHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD bytesRead {};
|
||||
|
||||
if (!SetFilePointer(handle, offset, NULL, 0))
|
||||
if (!SetFilePointer(hHandle, offset, NULL, 0))
|
||||
{
|
||||
AuWin32CloseHandle(hHandle);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!ReadFile(handle, &value, sizeof(Value_t), &bytesRead, NULL))
|
||||
if (!ReadFile(hHandle, &value, sizeof(Value_t), &dwBytesRead, NULL))
|
||||
{
|
||||
AuWin32CloseHandle(hHandle);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (bytesRead != sizeof(Value_t))
|
||||
if (dwBytesRead != sizeof(Value_t))
|
||||
{
|
||||
AuWin32CloseHandle(hHandle);
|
||||
return {};
|
||||
}
|
||||
|
||||
CloseHandle(handle);
|
||||
AuWin32CloseHandle(hHandle);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user