summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-09-26 09:35:19 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-09-26 09:47:58 +0100
commit8d01d16c4bc2531a37dca54526568fd5b533a40f (patch)
tree78d5964f80ef8a8a812ee9b90a571f51144b0c8a /i18npool
parentf670636245fb407277e38224058616833994ae3e (diff)
coverity#1241117 Negative array index read
Change-Id: I15787a4a2b964de3b12586c823be48c0289fea0f
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx87
1 files changed, 46 insertions, 41 deletions
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 5c421f9bb72e..9a5455df1cee 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -520,50 +520,55 @@ static sal_Int16 SAL_CALL getLanguageNumber( const Locale& rLocale)
OUString SAL_CALL NativeNumberSupplierService::getNativeNumberString(const OUString& aNumberString, const Locale& rLocale,
sal_Int16 nNativeNumberMode, Sequence< sal_Int32 >& offset) throw (RuntimeException)
{
+ if (!isValidNatNum(rLocale, nNativeNumberMode))
+ return aNumberString;
+
+ sal_Int16 langnum = getLanguageNumber(rLocale);
+ if (langnum == -1)
+ return aNumberString;
+
const Number *number = 0;
sal_Int16 num = -1;
- if (isValidNatNum(rLocale, nNativeNumberMode)) {
- sal_Int16 langnum = getLanguageNumber(rLocale);
- switch (nNativeNumberMode) {
- case NativeNumberMode::NATNUM0: // Ascii
- return NativeToAscii(aNumberString, 0, aNumberString.getLength(), offset, useOffset);
- case NativeNumberMode::NATNUM1: // Char, Lower
- num = natnum1[langnum];
- break;
- case NativeNumberMode::NATNUM2: // Char, Upper
- num = natnum2[langnum];
- break;
- case NativeNumberMode::NATNUM3: // Char, FullWidth
- num = NumberChar_FullWidth;
- break;
- case NativeNumberMode::NATNUM4: // Text, Lower, Long
- number = &natnum4[langnum];
- break;
- case NativeNumberMode::NATNUM5: // Text, Upper, Long
- number = &natnum5[langnum];
- break;
- case NativeNumberMode::NATNUM6: // Text, FullWidth
- number = &natnum6[langnum];
- break;
- case NativeNumberMode::NATNUM7: // Text. Lower, Short
- number = &natnum7[langnum];
- break;
- case NativeNumberMode::NATNUM8: // Text, Upper, Short
- number = &natnum8[langnum];
- break;
- case NativeNumberMode::NATNUM9: // Char, Hangul
- num = NumberChar_Hangul_ko;
- break;
- case NativeNumberMode::NATNUM10: // Text, Hangul, Long
- number = &natnum10;
- break;
- case NativeNumberMode::NATNUM11: // Text, Hangul, Short
- number = &natnum11;
- break;
- default:
- break;
- }
+ switch (nNativeNumberMode)
+ {
+ case NativeNumberMode::NATNUM0: // Ascii
+ return NativeToAscii(aNumberString, 0, aNumberString.getLength(), offset, useOffset);
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ num = natnum1[langnum];
+ break;
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ num = natnum2[langnum];
+ break;
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ num = NumberChar_FullWidth;
+ break;
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ number = &natnum4[langnum];
+ break;
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ number = &natnum5[langnum];
+ break;
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ number = &natnum6[langnum];
+ break;
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ number = &natnum7[langnum];
+ break;
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ number = &natnum8[langnum];
+ break;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ num = NumberChar_Hangul_ko;
+ break;
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ number = &natnum10;
+ break;
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ number = &natnum11;
+ break;
+ default:
+ break;
}
if (number || num >= 0) {