From c8e5d263bd80668e5807ee2b72a0a20c82cc7c66 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 4 Feb 2024 11:18:55 +0100 Subject: [PATCH] Thirdparty: upgrade to latest RapidJSON --- r5dev/thirdparty/rapidjson/schema.h | 6 ++++-- r5dev/thirdparty/rapidjson/writer.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/r5dev/thirdparty/rapidjson/schema.h b/r5dev/thirdparty/rapidjson/schema.h index 06f50efa..973e935f 100644 --- a/r5dev/thirdparty/rapidjson/schema.h +++ b/r5dev/thirdparty/rapidjson/schema.h @@ -367,7 +367,9 @@ public: uint64_t h = Hash(0, kObjectType); uint64_t* kv = stack_.template Pop(memberCount * 2); for (SizeType i = 0; i < memberCount; i++) - h ^= Hash(kv[i * 2], kv[i * 2 + 1]); // Use xor to achieve member order insensitive + // Issue #2205 + // Hasing the key to avoid key=value cases with bug-prone zero-value hash + h ^= Hash(Hash(0, kv[i * 2]), kv[i * 2 + 1]); // Use xor to achieve member order insensitive *stack_.template Push() = h; return true; } @@ -405,7 +407,7 @@ private: bool WriteBuffer(Type type, const void* data, size_t len) { // FNV-1a from http://isthe.com/chongo/tech/comp/fnv/ - uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type); + uint64_t h = Hash(RAPIDJSON_UINT64_C2(0xcbf29ce4, 0x84222325), type); const unsigned char* d = static_cast(data); for (size_t i = 0; i < len; i++) h = Hash(h, d[i]); diff --git a/r5dev/thirdparty/rapidjson/writer.h b/r5dev/thirdparty/rapidjson/writer.h index 142230d9..632e02ce 100644 --- a/r5dev/thirdparty/rapidjson/writer.h +++ b/r5dev/thirdparty/rapidjson/writer.h @@ -349,7 +349,7 @@ protected: bool WriteDouble(double d) { if (internal::Double(d).IsNanOrInf()) { - if (!(writeFlags & kWriteNanAndInfFlag)) + if (!(writeFlags & kWriteNanAndInfFlag) && !(writeFlags & kWriteNanAndInfNullFlag)) return false; if (writeFlags & kWriteNanAndInfNullFlag) { PutReserve(*os_, 4);