diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2019-06-01 19:01:21 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2019-06-01 19:01:21 +0300 |
commit | 33773c6f2a8711d4aa6656795db52c59a28580ec (patch) | |
tree | a1f059705643278ad2fcb25b645889158a4d7aa2 /src/liblzma/common/memcmplen.h | |
parent | tuklib_integer: Autodetect support for unaligned access on ARM. (diff) | |
download | xz-33773c6f2a8711d4aa6656795db52c59a28580ec.tar.xz |
liblzma: Use unaligned_readXXne functions instead of type punning.
Now gcc -fsanitize=undefined should be clean.
Thanks to Jeffrey Walton.
Diffstat (limited to 'src/liblzma/common/memcmplen.h')
-rw-r--r-- | src/liblzma/common/memcmplen.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/liblzma/common/memcmplen.h b/src/liblzma/common/memcmplen.h index c1efc9e2..62e79832 100644 --- a/src/liblzma/common/memcmplen.h +++ b/src/liblzma/common/memcmplen.h @@ -61,8 +61,8 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // to __builtin_clzll(). #define LZMA_MEMCMPLEN_EXTRA 8 while (len < limit) { - const uint64_t x = *(const uint64_t *)(buf1 + len) - - *(const uint64_t *)(buf2 + len); + const uint64_t x = unaligned_read64ne(buf1 + len) + - unaligned_read64ne(buf2 + len); if (x != 0) { # if defined(_M_X64) // MSVC or Intel C compiler on Windows unsigned long tmp; @@ -120,8 +120,8 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // Generic 32-bit little endian method # define LZMA_MEMCMPLEN_EXTRA 4 while (len < limit) { - uint32_t x = *(const uint32_t *)(buf1 + len) - - *(const uint32_t *)(buf2 + len); + uint32_t x = unaligned_read32ne(buf1 + len) + - unaligned_read32ne(buf2 + len); if (x != 0) { if ((x & 0xFFFF) == 0) { len += 2; @@ -143,8 +143,8 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // Generic 32-bit big endian method # define LZMA_MEMCMPLEN_EXTRA 4 while (len < limit) { - uint32_t x = *(const uint32_t *)(buf1 + len) - ^ *(const uint32_t *)(buf2 + len); + uint32_t x = unaligned_read32ne(buf1 + len) + ^ unaligned_read32ne(buf2 + len); if (x != 0) { if ((x & 0xFFFF0000) == 0) { len += 2; |