From: Victor Cebollada Date: Wed, 10 May 2017 13:39:51 +0000 (+0100) Subject: Fix access out of bounds in the text's multi-language support. X-Git-Tag: dali_1.2.39~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=aca65426b302c44e2c88f4e67a08be6096d07447;ds=sidebyside Fix access out of bounds in the text's multi-language support. * If the script is unknown it will access a vector out of bounds. Change-Id: Ia1f670f1f50296ec4a8d7b88401574e074147d40 Signed-off-by: Victor Cebollada --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp index 3904faa..c3f0b9b 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp @@ -1614,6 +1614,38 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) fontDescriptions10.PushBack( fontDescription1003 ); fontDescriptions10.PushBack( fontDescription1004 ); + FontRun fontRun1101 = + { + { + 0u, + 22u + }, + 5u + }; + Vector fontRuns11; + fontRuns11.PushBack( fontRun1101 ); + + FontDescriptionRun fontDescription1101 = + { + { + 0, + 22u + }, + const_cast( "TizenSans" ), + 9u, + TextAbstraction::FontWeight::NORMAL, + TextAbstraction::FontWidth::NORMAL, + TextAbstraction::FontSlant::NORMAL, + pointSize02, + true, + false, + false, + false, + true + }; + Vector fontDescriptions11; + fontDescriptions11.PushBack( fontDescription1101 ); + const ValidateFontsData data[] = { { @@ -1716,8 +1748,18 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) fontDescriptions10, fontRuns10 }, + { + "Unknown script -> changed to LATIN", + "WRC – The Official App", + "/tizen/TizenSansRegular.ttf", + TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 0u, + 22u, + fontDescriptions11, + fontRuns11 + }, }; - const unsigned int numberOfTests = 10u; + const unsigned int numberOfTests = 11u; for( unsigned int index = 0u; index < numberOfTests; ++index ) { diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 260bd5a..fd1d8e4 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -477,9 +477,9 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, currentFontId = fontId; // Get the script for the current character. - const Script script = GetScript( index, - scriptRunIt, - scriptRunEndIt ); + Script script = GetScript( index, + scriptRunIt, + scriptRunEndIt ); #ifdef DEBUG_ENABLED { @@ -494,6 +494,10 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, description.path.c_str() ); } #endif + if (script == TextAbstraction::UNKNOWN) + { + script = TextAbstraction::LATIN; + } // Validate whether the current character is supported by the given font. bool isValidFont = false;