From adbd9c6f0819a3ddd5a06237238e9becdb036e17 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 9 Nov 2019 13:47:16 +0200 Subject: [PATCH] atom: correct iteration count in hash function Fixup of ccab349 - unlike the commit message, hash a byte twice instead of zero times, which is probably better. This is how it was before. Signed-off-by: Ran Benita --- src/atom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.c b/src/atom.c index 43faecb..e78c68f 100644 --- a/src/atom.c +++ b/src/atom.c @@ -78,7 +78,7 @@ static inline uint32_t hash_buf(const char *string, size_t len) { uint32_t hash = 2166136261u; - for (size_t i = 0; i < len / 2; i++) { + for (size_t i = 0; i < (len + 1) / 2; i++) { hash ^= (uint8_t) string[i]; hash *= 0x01000193; hash ^= (uint8_t) string[len - 1 - i]; -- 2.7.4