Skip to content

Commit

Permalink
Fix object hashing in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
aikawayataro authored and miloyip committed Sep 28, 2023
1 parent b4a6da3 commit eee82cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/rapidjson/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ class Hasher {
uint64_t h = Hash(0, kObjectType);
uint64_t* kv = stack_.template Pop<uint64_t>(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<uint64_t>() = h;
return true;
}
Expand Down

0 comments on commit eee82cb

Please sign in to comment.