From cac30a436cab3641bba3b774d3d3ddbc426e7908 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Wed, 5 Jun 2019 22:43:28 +0200 Subject: Clean up logic in memory_cleanse() for MSVC Commit fbf327b13868861c2877c5754caf5a9816f2603c ("Minimal code changes to allow msvc compilation.") was indeed minimal in terms of lines touched. But as a result of that minimalism it changed the logic in memory_cleanse() to first call std::memset() and then additionally the MSVC-specific SecureZeroMemory() function, and it also moved a comment to the wrong location. This commit removes the superfluous call to std::memset() on MSVC and ensures that the comment is in the right position again. --- src/support/cleanse.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/support') diff --git a/src/support/cleanse.cpp b/src/support/cleanse.cpp index 17a4a4c2b2..f895e96568 100644 --- a/src/support/cleanse.cpp +++ b/src/support/cleanse.cpp @@ -30,14 +30,14 @@ */ void memory_cleanse(void *ptr, size_t len) { +#if defined(_MSC_VER) + SecureZeroMemory(ptr, len); +#else std::memset(ptr, 0, len); /* As best as we can tell, this is sufficient to break any optimisations that 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) - SecureZeroMemory(ptr, len); -#else __asm__ __volatile__("" : : "r"(ptr) : "memory"); #endif } -- cgit v1.2.3