From 58e3caa4522155d9e4ab9176f06682284ad9b6aa Mon Sep 17 00:00:00 2001 From: Lucian Grijincu Date: Mon, 1 Feb 2016 11:51:51 -0800 Subject: [PATCH] folly: Hash: use loadUnassigned to avoid UB in hsieh_hash32_buf (fsanitize=alignment) Reviewed By: philippv Differential Revision: D2886152 fb-gh-sync-id: 64c3543db831c72c7f4cf307867223270293066e --- folly/Hash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/folly/Hash.h b/folly/Hash.h index 7e44fbb2..0def3efc 100644 --- a/folly/Hash.h +++ b/folly/Hash.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -277,7 +278,7 @@ inline uint64_t fnv64(const std::string& str, * Paul Hsieh: http://www.azillionmonkeys.com/qed/hash.html */ -#define get16bits(d) (*((const uint16_t*) (d))) +#define get16bits(d) folly::loadUnaligned(d) inline uint32_t hsieh_hash32_buf(const void* buf, size_t len) { // forcing signed char, since other platforms can use unsigned -- 2.34.1