Skip to content
Snippets Groups Projects
Verified Commit 1dc3666e authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Tomas Krizek
Browse files

contrib/murmurhash3: fix occasional undefined behavior

murmurhash3.c:43:40: runtime error: addition of unsigned offset
                     to 0x7ffce41c2014 overflowed to 0x7ffce41c2000
The `i` was used in a super-ugly way; I suspect the only reason was
to optimize that end-loop condition was zero comparison *vomit*
parent 94896b2e
Branches
Tags
1 merge request!1167various undefined-behavior fixes
Pipeline #79547 failed with stages
in 3 minutes and 7 seconds
......@@ -36,11 +36,10 @@ uint32_t hash(const char* data, size_t len_)
//----------
// body
int i;
for(i = -nblocks; i; i++)
for(int i = 0; i < nblocks; ++i)
{
uint32_t k1;
memcpy(&k1, data + nblocks * 4 + i * sizeof(k1), sizeof(k1));
memcpy(&k1, data + i * sizeof(k1), sizeof(k1));
k1 *= c1;
k1 = rotl32(k1, 15);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment