summaryrefslogtreecommitdiff
path: root/i18nutil
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-28 08:52:52 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-28 08:55:11 +0200
commitce583af68915b83cfaa0bd4f1a2f49c92767bc8e (patch)
tree13702f81a0b4f0bbbecdf9a45158f3aff88cdbd1 /i18nutil
parent6e7986a2fccae2d8dac7f96a8e6b852e93e2513b (diff)
Avoid undefined left shift of negative value
Change-Id: If4e7f6fca3f6afbbeaa79e00706be08d674e2aeb
Diffstat (limited to 'i18nutil')
-rw-r--r--i18nutil/source/utility/casefolding.cxx13
1 files changed, 8 insertions, 5 deletions
diff --git a/i18nutil/source/utility/casefolding.cxx b/i18nutil/source/utility/casefolding.cxx
index cbe7ea91b833..3fb7845afa66 100644
--- a/i18nutil/source/utility/casefolding.cxx
+++ b/i18nutil/source/utility/casefolding.cxx
@@ -79,12 +79,14 @@ Mapping& casefolding::getConditionalValue(const sal_Unicode* str, sal_Int32 pos,
Mapping& casefolding::getValue(const sal_Unicode* str, sal_Int32 pos, sal_Int32 len, Locale& aLocale, sal_uInt8 nMappingType) throw (RuntimeException)
{
- static Mapping dummy = { 0, 1, { 0, 0, 0 } };
- sal_Int16 address = CaseMappingIndex[str[pos] >> 8] << 8;
+ static Mapping dummy = { 0, 1, { 0, 0, 0 } };
+ sal_Int16 address = CaseMappingIndex[str[pos] >> 8];
- dummy.map[0] = str[pos];
+ dummy.map[0] = str[pos];
- if (address >= 0 && (CaseMappingValue[address += (str[pos] & 0xFF)].type & nMappingType)) {
+ if (address >= 0) {
+ address = (address << 8) + (str[pos] & 0xFF);
+ if (CaseMappingValue[address].type & nMappingType) {
sal_uInt8 type = CaseMappingValue[address].type;
if (type & ValueTypeNotValue) {
if (CaseMappingValue[address].value == 0)
@@ -105,7 +107,8 @@ Mapping& casefolding::getValue(const sal_Unicode* str, sal_Int32 pos, sal_Int32
} else
dummy.map[0] = CaseMappingValue[address].value;
}
- return dummy;
+ }
+ return dummy;
}
inline bool SAL_CALL