Fix undefined behavior due to unaligned read

This commit is contained in:
Yuriy Chernyshov 2021-06-22 13:00:05 +03:00
parent 23486ff86c
commit 1f1c61ce94

View File

@ -8,6 +8,7 @@
// non-native version will be less than optimal.
#include "MurmurHash3.h"
#include <string.h>
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
@ -54,7 +55,9 @@ inline uint64_t rotl64 ( uint64_t x, int8_t r )
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
{
return p[i];
uint32_t res;
memcpy(&res, p + i, sizeof(res));
return res;
}
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )