summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2015-02-18 13:43:06 +0000
committerPierre Bourdon <delroth@gmail.com>2015-02-18 13:43:06 +0000
commit96041a5aca33d34a11f65d35a56792d9191b2f4e (patch)
tree8ec8c31d83172d48ec9b7293611cefc7b3f03bb1 /Source/Core
parentef2fba2e8521666455576f332b472ab65e8f499a (diff)
parentf6c9b8243e719f6e3ee632fc1b9bf54bfbcbf76c (diff)
Merge pull request #2068 from mimimi085181/hash-fix
GetCRC32: Fix the hash for the last byte(s)
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Hash.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp
index 4a0df743be..63caced040 100644
--- a/Source/Core/Common/Hash.cpp
+++ b/Source/Core/Common/Hash.cpp
@@ -252,9 +252,14 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
if (data < end - Step * 2)
h[2] = _mm_crc32_u64(h[2], data[Step * 2]);
- const u8 *data2 = (const u8*)end;
+ if (len & 7)
+ {
+ u64 temp = 0;
+ memcpy(&temp, end, len & 7);
+ h[0] = _mm_crc32_u64(h[0], temp);
+ }
+
// FIXME: is there a better way to combine these partial hashes?
- h[0] = _mm_crc32_u64(h[0], u64(data2[0]));
return h[0] + (h[1] << 10) + (h[2] << 21) + (h[3] << 32);
#else
return 0;