diff --git a/Source/Core/Common/Src/Hash.cpp b/Source/Core/Common/Src/Hash.cpp index 62ea25519e..46747ce157 100644 --- a/Source/Core/Common/Src/Hash.cpp +++ b/Source/Core/Common/Src/Hash.cpp @@ -167,7 +167,13 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples) const u8 * data = (const u8*)src; const int nblocks = len / 16; u32 Step = (len / 8); - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; @@ -245,7 +251,13 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; while(data < end) @@ -275,7 +287,13 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; while(data < end) @@ -318,7 +336,13 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) u32 Step = (len/4); const u32 *data = (const u32 *)src; const u32 *end = data + Step; - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; while(data < end) @@ -390,7 +414,13 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples) u32 out[2]; const int nblocks = len / 8; u32 Step = (len / 4); - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; @@ -464,7 +494,13 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) u32 Step = (len / 8); const u64 *data = (const u64 *)src; const u64 *end = data + Step; - if(samples == 0) samples = Step; + if(samples == 0) + { + if (Step == 0) + samples = 1; + else + samples = Step; + } Step = Step / samples; if(Step < 1) Step = 1; while(data < end)