diff options
author | Zufu Liu <unknown> | 2019-06-29 11:57:11 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2019-06-29 11:57:11 +1000 |
commit | 55446b8967ed0a7f66502424d309f0b8fa74919f (patch) | |
tree | 7ba19e751fd3a41c8e08e58d5c210c523e291c5c /src | |
parent | 093b2d6514bbf5de6dfa47c4cc0381378891ece4 (diff) | |
download | scintilla-mirror-55446b8967ed0a7f66502424d309f0b8fa74919f.tar.gz |
Backport: Bug [#2115]. Fix undefined behaviour of shifting negative values.
Backport of changeset 7612:d70ccc4f172a.
Diffstat (limited to 'src')
-rw-r--r-- | src/PositionCache.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
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<const unsigned char *>(s); + unsigned int ret = us[0] << 7; for (unsigned int i=0; i<len_; i++) { ret *= 1000003; - ret ^= s[i]; + ret ^= us[i]; } ret *= 1000003; ret ^= len_; |