diff --git a/core/libs/tests/GuestCndAtThreadExit.cpp b/core/libs/tests/GuestCndAtThreadExit.cpp index b01f02ab0908..a237e07a760e 100644 --- a/core/libs/tests/GuestCndAtThreadExit.cpp +++ b/core/libs/tests/GuestCndAtThreadExit.cpp @@ -14,6 +14,11 @@ void* operator new(std::size_t size) { throw std::bad_alloc(); } +void* operator new(std::size_t size, const std::nothrow_t&) noexcept { + if (failAllocations) return nullptr; + return std::malloc(size ? size : 1); +} + void operator delete(void* memory) noexcept { std::free(memory); } void operator delete(void* memory, std::size_t) noexcept { std::free(memory); }