mirror of
https://github.com/google/leveldb.git
synced 2025-02-04 07:10:10 +08:00
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:
parent
068d5ee1a3
commit
dae879c604
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user