+8
-3
lines changedFilter options
+8
-3
lines changed Original file line number Diff line number Diff line change
@@ -402,9 +402,14 @@ uint32_t _upb_Hash(const void* p, size_t n, uint64_t seed) {
402
402
return Wyhash(p, n, seed, kWyhashSalt);
403
403
}
404
404
405
-
// Returns a seed for upb's hash function. For now this is just a hard-coded
406
-
// constant, but we are going to randomize it soon.
407
-
static uint64_t _upb_Seed(void) { return 0x69835f69597ec1cc; }
405
+
static const void* const _upb_seed;
406
+
407
+
// Returns a random seed for upb's hash function. This does not provide
408
+
// high-quality randomness, but it should be enough to prevent unit tests from
409
+
// relying on a deterministic map ordering. By returning the address of a
410
+
// variable, we are able to get some randomness for free provided that ASLR is
411
+
// enabled.
412
+
static uint64_t _upb_Seed(void) { return (uint64_t)&_upb_seed; }
408
413
409
414
static uint32_t _upb_Hash_NoSeed(const char* p, size_t n) {
410
415
return _upb_Hash(p, n, _upb_Seed());
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4