mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Bug 1804499 - [1/4] Handle Windows error code consistently r=glandium
The real ::VirtualAlloc does not modify the existing last-error code in case of success; therefore, neither should we. Differential Revision: https://phabricator.services.mozilla.com/D164105
This commit is contained in:
parent
2e0b78ffc1
commit
a27f258c20
@ -1517,6 +1517,8 @@ static inline StallSpecs GetStallSpecs() {
|
||||
// Ref: https://docs.microsoft.com/en-us/troubleshoot/windows-client/performance/slow-page-file-growth-memory-allocation-errors
|
||||
[[nodiscard]] void* MozVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,
|
||||
DWORD flAllocationType, DWORD flProtect) {
|
||||
DWORD const lastError = ::GetLastError();
|
||||
|
||||
constexpr auto IsOOMError = [] {
|
||||
switch (::GetLastError()) {
|
||||
// This is the usual error result from VirtualAlloc for OOM.
|
||||
@ -1553,7 +1555,7 @@ static inline StallSpecs GetStallSpecs() {
|
||||
// The OOM status has been handled, and should not be reported to
|
||||
// telemetry.
|
||||
if (IsOOMError()) {
|
||||
::SetLastError(0);
|
||||
::SetLastError(lastError);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user