File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Library
101
101
set (CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" CACHE PATH "PDB (MSVC debug symbol)output dir." )
102
102
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" CACHE PATH "Executable/dll output dir." )
103
103
104
+ include (CheckFunctionExists)
105
+ check_function_exists(memset_s HAVE_MEMSET_S)
106
+ if (HAVE_MEMSET_S)
107
+ add_definitions ("-DHAVE_MEMSET_S=1" )
108
+ endif ()
109
+
104
110
set (JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
105
111
106
112
configure_file ("${PROJECT_SOURCE_DIR} /version.in"
Original file line number Diff line number Diff line change 8
8
9
9
#include < cstring>
10
10
#include < memory>
11
+ #include < algorithm>
11
12
12
13
#pragma pack(push)
13
14
#pragma pack()
@@ -38,8 +39,14 @@ template <typename T> class SecureAllocator {
38
39
* The memory block is filled with zeroes before being released.
39
40
*/
40
41
void deallocate (pointer p, size_type n) {
41
- // memset_s is used because memset may be optimized away by the compiler
42
+ # if defined(HAVE_MEMSET_S)
42
43
memset_s (p, n * sizeof (T), 0 , n * sizeof (T));
44
+ #elif defined(_WIN32)
45
+ RtlSecureZeroMemory (p, n * sizeof (T));
46
+ #else
47
+ std::fill_n (reinterpret_cast <volatile unsigned char *>(p), n, 0 );
48
+ #endif
49
+
43
50
// free using "global operator delete"
44
51
::operator delete (p);
45
52
}
You can’t perform that action at this time.
0 commit comments