aboutsummaryrefslogtreecommitdiff
path: root/src/support/cleanse.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-12-13 13:32:00 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-12-13 14:05:25 +0100
commit68e021e3a35d1e88d6075ea8b05a8e3a40a64e29 (patch)
treea602d99d1d242f8a603127dcbc435944e5cea52f /src/support/cleanse.cpp
parentba2f19504c6b1302a93accbb50383f422c54df43 (diff)
parentfbf327b13868861c2877c5754caf5a9816f2603c (diff)
Merge #11558: Minimal code changes to allow msvc compilation
fbf327b Minimal code changes to allow msvc compilation. (Aaron Clauson) Pull request description: These changes are required to allow the Bitcoin source to build with Microsoft's C++ compiler (#11562 is also required). I looked around for a better place for the typedef of ssize_t which is in random.h. The best candidate looks like src/compat.h but I figured including that header in random.h is a bigger change than the typedef. Note that the same typedef is in at least two other places including the OpenSSL and Berkeley DB headers so some of the Bitcoin code already picks it up. Tree-SHA512: aa6cc6283015e08ab074641f9abdc116c4dc58574dc90f75e7a5af4cc82946d3052370e5cbe855fb6180c00f8dc66997d3724ff0412e4b7417e51b6602154825
Diffstat (limited to 'src/support/cleanse.cpp')
-rw-r--r--src/support/cleanse.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/support/cleanse.cpp b/src/support/cleanse.cpp
index 82cdfe707b..8d3c7369b4 100644
--- a/src/support/cleanse.cpp
+++ b/src/support/cleanse.cpp
@@ -7,6 +7,10 @@
#include <cstring>
+#if defined(_MSC_VER)
+#include <Windows.h> // For SecureZeroMemory.
+#endif
+
/* Compilers have a bad habit of removing "superfluous" memset calls that
* are trying to zero memory. For example, when memset()ing a buffer and
* then free()ing it, the compiler might decide that the memset is
@@ -32,7 +36,7 @@ void memory_cleanse(void *ptr, size_t len)
might try to eliminate "superfluous" memsets. If there's an easy way to
detect memset_s, it would be better to use that. */
#if defined(_MSC_VER)
- __asm;
+ SecureZeroMemory(ptr, len);
#else
__asm__ __volatile__("" : : "r"(ptr) : "memory");
#endif