Merge "Update code of system and text for reporting Klocwork." into tizen_2.2
[platform/framework/native/appfw.git] / src / text / FText_Iso885916EncodingCore.cpp
index cc7490d..ed5fb90 100644 (file)
@@ -59,7 +59,7 @@ _Iso885916EncodingCore::~_Iso885916EncodingCore(void)
 _EncodingCore*
 _Iso885916EncodingCore::GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo)
 {
-       SysTryReturn(NID_TEXT, encodingFrom == L"ISO-8859-16", null, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE] It is the unsupported type.");
+       SysTryReturn(NID_TEXT, encodingFrom == L"ISO-8859-16", null, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE] It is not the ISO-8859-16 type.");
        _Iso885916EncodingCore* pEncodingCore = new (std::nothrow) _Iso885916EncodingCore;
        SysTryReturn(NID_TEXT, pEncodingCore, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
        return pEncodingCore;
@@ -91,6 +91,10 @@ _Iso885916EncodingCore::GetByteCount(const wchar_t* pSrc, int srcLength, int& re
 
                                if (!(*pUnicodeStr & 0xFF00))
                                {
+                                       int tableSize = sizeof(ISO_8859_16_UNICODE_TABLE) / sizeof(ISO_8859_16_UNICODE_TABLE[0]);
+                                       SysTryReturn(NID_TEXT, *pUnicodeStr - 0xA0 < tableSize, E_INVALID_ENCODING_RANGE, E_INVALID_ENCODING_RANGE,
+                                               "[E_INVALID_ENCODING_RANGE] It is an invalid byte.");
+
                                        if (ISO_8859_16_UNICODE_TABLE[*pUnicodeStr - 0xA0] != *pUnicodeStr)
                                        {
                                                return E_INVALID_ENCODING_RANGE;