Skip to content

Commit cac30a4

Browse files
Clean up logic in memory_cleanse() for MSVC
Commit fbf327b ("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.
1 parent 52ec4c6 commit cac30a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/support/cleanse.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
*/
3131
void memory_cleanse(void *ptr, size_t len)
3232
{
33+
#if defined(_MSC_VER)
34+
SecureZeroMemory(ptr, len);
35+
#else
3336
std::memset(ptr, 0, len);
3437

3538
/* As best as we can tell, this is sufficient to break any optimisations that
3639
might try to eliminate "superfluous" memsets. If there's an easy way to
3740
detect memset_s, it would be better to use that. */
38-
#if defined(_MSC_VER)
39-
SecureZeroMemory(ptr, len);
40-
#else
4141
__asm__ __volatile__("" : : "r"(ptr) : "memory");
4242
#endif
4343
}

0 commit comments

Comments
 (0)