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 | 24bff87107d89a09e724993e053e7151945596e8 (patch) | |
tree | eb17aae741778d025d558babb543cbfad08d6e4c /src/PositionCache.cxx | |
parent | 70f71bdbb2ba9da03cbfb3b7af0b5e2c2a447b3e (diff) | |
download | scintilla-mirror-24bff87107d89a09e724993e053e7151945596e8.tar.gz |
Bug [#2115]. Fix undefined behaviour of shifting negative values.
Diffstat (limited to 'src/PositionCache.cxx')
-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 ea281f7ab..e9edb84e7 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -723,10 +723,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_; |