From 55446b8967ed0a7f66502424d309f0b8fa74919f Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Sat, 29 Jun 2019 11:57:11 +1000 Subject: Backport: Bug [#2115]. Fix undefined behaviour of shifting negative values. Backport of changeset 7612:d70ccc4f172a. --- src/PositionCache.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 8910a2955..03393536d 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -615,10 +615,11 @@ bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, } unsigned int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) noexcept { - unsigned int ret = s[0] << 7; + const unsigned char *us = reinterpret_cast(s); + unsigned int ret = us[0] << 7; for (unsigned int i=0; i