Fix unaligned access in xx_loadl_32 & xx_storel_32
Tested:
cmake ../aom -DCONFIG_LOWBITDEPTH=1 -DSANITIZE=undefined -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
./test_libaom --gtest_filter=*InvalidFileTest*
Change-Id: I1ec76944eeed0ed688f532a3d83a8b2079ee27b8
diff --git a/aom_dsp/x86/synonyms.h b/aom_dsp/x86/synonyms.h
index 1e9f1e2..c6f18ae 100644
--- a/aom_dsp/x86/synonyms.h
+++ b/aom_dsp/x86/synonyms.h
@@ -13,6 +13,7 @@
#define AOM_AOM_DSP_X86_SYNONYMS_H_
#include <immintrin.h>
+#include <string.h>
#include "config/aom_config.h"
@@ -28,7 +29,9 @@
// Loads and stores to do away with the tedium of casting the address
// to the right type.
static INLINE __m128i xx_loadl_32(const void *a) {
- return _mm_cvtsi32_si128(*(const uint32_t *)a);
+ int val;
+ memcpy(&val, a, sizeof(val));
+ return _mm_cvtsi32_si128(val);
}
static INLINE __m128i xx_loadl_64(const void *a) {
@@ -44,7 +47,8 @@
}
static INLINE void xx_storel_32(void *const a, const __m128i v) {
- *(uint32_t *)a = _mm_cvtsi128_si32(v);
+ int val = _mm_cvtsi128_si32(v);
+ memcpy(a, &val, sizeof(val));
}
static INLINE void xx_storel_64(void *const a, const __m128i v) {