Merge bitcoin/bitcoin#26950: cleanse: switch to SecureZeroMemory for Windows cross-compile

c399c80a09a393d38368a44ef04753e9f62350f0 cleanse: Use SecureZeroMemory for mingw-w64 (release) builds (fanquake)

Pull request description:

  This PR switches our Windows release builds to use the [`SecureZeroMemory()`](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)) provided by mingw-w64.

ACKs for top commit:
  sipa:
    utACK c399c80a09a393d38368a44ef04753e9f62350f0
  TheCharlatan:
    ACK c399c80a09a393d38368a44ef04753e9f62350f0

Tree-SHA512: dbb20b16c85061d2f9408a3cf69cecc16765f8f61b25a1707146767b664c7ad0caf36975380814ef8e7c49a30199daebac6d5d7a3585354d1adac8e9770199c6
This commit is contained in:
merge-script 2024-07-26 07:08:49 +01:00 committed by pasta
parent 57945ce337
commit df3c2392ca
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -7,14 +7,14 @@
#include <cstring> #include <cstring>
#if defined(_MSC_VER) #if defined(WIN32)
#include <Windows.h> // For SecureZeroMemory. #include <windows.h>
#endif #endif
void memory_cleanse(void *ptr, size_t len) void memory_cleanse(void *ptr, size_t len)
{ {
#if defined(_MSC_VER) #if defined(WIN32)
/* SecureZeroMemory is guaranteed not to be optimized out by MSVC. */ /* SecureZeroMemory is guaranteed not to be optimized out. */
SecureZeroMemory(ptr, len); SecureZeroMemory(ptr, len);
#else #else
std::memset(ptr, 0, len); std::memset(ptr, 0, len);