1. hyphenation.GetDictionaryEncoding() can return nullptr logically.
We must doing error check for it.
2. hyphenation.GetWordHyphens() could return empty list if their
was some error exist at hyphenation. TextUpdate logic must consider it.
3. Some environment values didnt restore as previous value.
Let we make revert them.
Change-Id: I69fa81f6983de02a8d93566ddc724155dc25c6d4
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
Vector<bool> hyphens = GetWordHyphens(hyphenation, utf32Characters.Begin() + index, wordEnd - index, nullptr);
- for(CharacterIndex i = 0; i < (wordEnd - index); i++)
+ for(CharacterIndex i = 0; i < (wordEnd - index) && i < hyphens.Count(); i++)
{
if(hyphens[i])
{
{
// Keep the current locale environment.
char* langPtr = getenv("LANG");
- gLocaleLang = std::string(langPtr);
+ if(langPtr)
+ {
+ gLocaleLang = std::string(langPtr);
+ }
char* languagePtr = getenv("LANGUAGE");
- gLocaleLanguage = std::string(languagePtr);
+ if(languagePtr)
+ {
+ gLocaleLanguage = std::string(languagePtr);
+ }
// Set the locale environment to Arabic.
setenv("LANG", "en_GB.UTF-8", 1);
void dali_textselectionpopupmirroringltr_cleanup(void)
{
// Restore the locale environment.
- setenv("LANG", gLocaleLang.c_str(), 1);
- setenv("LANGUAGE", gLocaleLanguage.c_str(), 1);
+ if(gLocaleLang.empty())
+ {
+ unsetenv("LANG");
+ }
+ else
+ {
+ setenv("LANG", gLocaleLang.c_str(), 1);
+ }
+ if(gLocaleLanguage.empty())
+ {
+ unsetenv("LANGUAGE");
+ }
+ else
+ {
+ setenv("LANGUAGE", gLocaleLanguage.c_str(), 1);
+ }
test_return_value = TET_PASS;
}
{
// Keep the current locale environment.
char* langPtr = getenv("LANG");
- gLocaleLang = std::string(langPtr);
+ if(langPtr)
+ {
+ gLocaleLang = std::string(langPtr);
+ }
char* languagePtr = getenv("LANGUAGE");
- gLocaleLanguage = std::string(languagePtr);
+ if(languagePtr)
+ {
+ gLocaleLanguage = std::string(languagePtr);
+ }
// Set the locale environment to Arabic.
setenv("LANG", "ar_AE.UTF-8", 1);
void dali_textselectionpopupmirroringrtl_cleanup(void)
{
// Restore the locale environment.
- setenv("LANG", gLocaleLang.c_str(), 1);
- setenv("LANGUAGE", gLocaleLanguage.c_str(), 1);
+ if(gLocaleLang.empty())
+ {
+ unsetenv("LANG");
+ }
+ else
+ {
+ setenv("LANG", gLocaleLang.c_str(), 1);
+ }
+ if(gLocaleLanguage.empty())
+ {
+ unsetenv("LANGUAGE");
+ }
+ else
+ {
+ setenv("LANGUAGE", gLocaleLanguage.c_str(), 1);
+ }
test_return_value = TET_PASS;
}
Vector<bool> hyphens = GetWordHyphens(mModule.GetHyphenation(), utf32Characters.Begin() + index, wordEnd - index, nullptr);
- for(CharacterIndex i = 0; i < (wordEnd - index); i++)
+ for(CharacterIndex i = 0; i < (wordEnd - index) && i < hyphens.Size(); i++)
{
if(hyphens[i])
{
Vector<bool> hyphens = GetWordHyphens(hyphenation, utf32Characters.Begin() + index, wordEnd - index, nullptr);
- for(CharacterIndex i = 0; i < (wordEnd - index); i++)
+ for(CharacterIndex i = 0; i < (wordEnd - index) && i < hyphens.Size(); i++)
{
if(hyphens[i])
{
// first get the needed encoding
std::string text;
- if(strcmp(hyphenation.GetDictionaryEncoding(lang), UTF8) == 0)
+ const char* dictionaryEncodingName = hyphenation.GetDictionaryEncoding(lang);
+ if(DALI_LIKELY(dictionaryEncodingName) && strcmp(dictionaryEncodingName, UTF8) == 0)
{
Utf32ToUtf8(word, wordSize, text);
}