Skip to content

Fix flag -DJSONCPP_USE_SECURE_MEMORY:BOOL=TRUE #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/json/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ using LargestUInt = UInt64;

template <typename T>
using Allocator =
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
typename std::conditional<JSONCPP_USE_SECURE_MEMORY, SecureAllocator<T>,
std::allocator<T>>::type;
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
using IStringStream =
Expand Down
2 changes: 1 addition & 1 deletion include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class JSON_API Value {
int compare(const Value& other) const;

const char* asCString() const; ///< Embedded zeroes could cause you trouble!
#if JSONCPP_USING_SECURE_MEMORY
#if JSONCPP_USE_SECURE_MEMORY
unsigned getCStringLength() const; // Allows you to understand the length of
// the CString
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/json/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
(JSONCPP_VERSION_PATCH << 8))

#if !defined(JSONCPP_USE_SECURE_MEMORY)
#define JSONCPP_USING_SECURE_MEMORY 0
#define JSONCPP_USE_SECURE_MEMORY 0
#endif
// If non-zero, the library zeroes any memory that it has allocated before
// it frees its memory.
Expand Down
8 changes: 4 additions & 4 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ inline static void decodePrefixedString(bool isPrefixed, char const* prefixed,
/** Free the string duplicated by
* duplicateStringValue()/duplicateAndPrefixStringValue().
*/
#if JSONCPP_USING_SECURE_MEMORY
#if JSONCPP_USE_SECURE_MEMORY
static inline void releasePrefixedStringValue(char* value) {
unsigned length = 0;
char const* valueDecoded;
Expand All @@ -180,10 +180,10 @@ static inline void releaseStringValue(char* value, unsigned length) {
memset(value, 0, size);
free(value);
}
#else // !JSONCPP_USING_SECURE_MEMORY
#else // !JSONCPP_USE_SECURE_MEMORY
static inline void releasePrefixedStringValue(char* value) { free(value); }
static inline void releaseStringValue(char* value, unsigned) { free(value); }
#endif // JSONCPP_USING_SECURE_MEMORY
#endif // JSONCPP_USE_SECURE_MEMORY

} // namespace Json

Expand Down Expand Up @@ -601,7 +601,7 @@ const char* Value::asCString() const {
return this_str;
}

#if JSONCPP_USING_SECURE_MEMORY
#if JSONCPP_USE_SECURE_MEMORY
unsigned Value::getCStringLength() const {
JSON_ASSERT_MESSAGE(type() == stringValue,
"in Json::Value::asCString(): requires stringValue");
Expand Down
2 changes: 1 addition & 1 deletion src/test_lib_json/jsontest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Json::String ToJsonString(const char* toConvert) {

Json::String ToJsonString(Json::String in) { return in; }

#if JSONCPP_USING_SECURE_MEMORY
#if JSONCPP_USE_SECURE_MEMORY
Json::String ToJsonString(std::string in) {
return Json::String(in.data(), in.data() + in.length());
}
Expand Down
2 changes: 1 addition & 1 deletion src/test_lib_json/jsontest.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ TestResult& checkEqual(TestResult& result, T expected, U actual,

Json::String ToJsonString(const char* toConvert);
Json::String ToJsonString(Json::String in);
#if JSONCPP_USING_SECURE_MEMORY
#if JSONCPP_USE_SECURE_MEMORY
Json::String ToJsonString(std::string in);
#endif

Expand Down
Loading