-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Open
Description
Lines 676 to 680 in 0f53e9e
unsigned char *p = (unsigned char *) v1; | |
while (*p++) | |
hash = (hash << 5) - (hash + *p); | |
The *p++
increment happens before the hash calculation, so when *p
is referenced inside the loop, Its actually looking at the character after the one that was just tested.
This means:
- The first character of the string is never hashed
- We are hashing one character past where we should be (potentially garbage memory after the null terminator)
Any two UTF‑8 strings that only differ in their initial character (e.g., "abc" vs. "xbc") will therefore produce identical hash values and single‑character strings hash to zero.
Metadata
Metadata
Assignees
Labels
No labels