diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-09-26 09:32:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-09-26 09:47:58 +0100 |
commit | f670636245fb407277e38224058616833994ae3e (patch) | |
tree | bfedf947f067a9d2a7726dddd9e17760de339eae /i18npool | |
parent | faf99f6f405e076d5c9ab95c876ae1ffb896f8d1 (diff) |
coverity#1241372 Negative array index read
Change-Id: I73bae29c6cc737d341381c010face6b587b31598
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/nativenumber/nativenumbersupplier.cxx | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx index a8f08badbab4..5c421f9bb72e 100644 --- a/i18npool/source/nativenumber/nativenumbersupplier.cxx +++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx @@ -611,28 +611,38 @@ sal_Unicode SAL_CALL NativeNumberSupplierService::getNativeNumberChar( const sal return j; return inChar; } - else if (isNumber(inChar) && isValidNatNum(rLocale, nNativeNumberMode)) { - sal_Int16 langnum = getLanguageNumber(rLocale); - switch (nNativeNumberMode) { - case NativeNumberMode::NATNUM1: // Char, Lower - case NativeNumberMode::NATNUM4: // Text, Lower, Long - case NativeNumberMode::NATNUM7: // Text. Lower, Short - return NumberChar[natnum1[langnum]][inChar - NUMBER_ZERO]; - case NativeNumberMode::NATNUM2: // Char, Upper - case NativeNumberMode::NATNUM5: // Text, Upper, Long - case NativeNumberMode::NATNUM8: // Text, Upper, Short - return NumberChar[natnum2[langnum]][inChar - NUMBER_ZERO]; - case NativeNumberMode::NATNUM3: // Char, FullWidth - case NativeNumberMode::NATNUM6: // Text, FullWidth - return NumberChar[NumberChar_FullWidth][inChar - NUMBER_ZERO]; - case NativeNumberMode::NATNUM9: // Char, Hangul - case NativeNumberMode::NATNUM10: // Text, Hangul, Long - case NativeNumberMode::NATNUM11: // Text, Hangul, Short - return NumberChar[NumberChar_Hangul_ko][inChar - NUMBER_ZERO]; - default: - break; - } + + if (!isNumber(inChar)) + return inChar; + + if (!isValidNatNum(rLocale, nNativeNumberMode)) + return inChar; + + sal_Int16 langnum = getLanguageNumber(rLocale); + if (langnum == -1) + return inChar; + + switch (nNativeNumberMode) + { + case NativeNumberMode::NATNUM1: // Char, Lower + case NativeNumberMode::NATNUM4: // Text, Lower, Long + case NativeNumberMode::NATNUM7: // Text. Lower, Short + return NumberChar[natnum1[langnum]][inChar - NUMBER_ZERO]; + case NativeNumberMode::NATNUM2: // Char, Upper + case NativeNumberMode::NATNUM5: // Text, Upper, Long + case NativeNumberMode::NATNUM8: // Text, Upper, Short + return NumberChar[natnum2[langnum]][inChar - NUMBER_ZERO]; + case NativeNumberMode::NATNUM3: // Char, FullWidth + case NativeNumberMode::NATNUM6: // Text, FullWidth + return NumberChar[NumberChar_FullWidth][inChar - NUMBER_ZERO]; + case NativeNumberMode::NATNUM9: // Char, Hangul + case NativeNumberMode::NATNUM10: // Text, Hangul, Long + case NativeNumberMode::NATNUM11: // Text, Hangul, Short + return NumberChar[NumberChar_Hangul_ko][inChar - NUMBER_ZERO]; + default: + break; } + return inChar; } |