fix(hash): fix nullptr ub in hash function

pass 0 int const char* will be nullptr. nullptr + 4 is ub,
This commit is contained in:
WangTingZheng 2023-07-10 14:54:03 +08:00
parent 068d5ee1a3
commit dae879c604

View File

@ -27,7 +27,7 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
uint32_t h = seed ^ (n * m);
// Pick up four bytes at a time
while (data + 4 <= limit) {
while (data != nullptr && data + 4 <= limit) {
uint32_t w = DecodeFixed32(data);
data += 4;
h += w;