include/unotools/localedatawrapper.hxx     |    3 +--
 unotools/source/i18n/localedatawrapper.cxx |   12 +++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

New commits:
commit 60b9c16bd482e43cfc5d70d807b84df442707a83
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Nov 4 11:31:33 2021 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Nov 4 11:42:12 2021 +0100

    fix potential out-of-bounds access in LocaleDataWrapper
    
    after
        commit 86b345a963a64fd9b9a3cab522b3ac2e909977fd
        Date:   Sat May 1 08:30:46 2021 +0200
        tdf#79049 speed up OOXML workbook load (4)
    if the number of reserved words returned by the locale is not correct.
    
    Change-Id: I1c709060a5f4e24c4278f3c36310364d10545f14
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124677
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/include/unotools/localedatawrapper.hxx 
b/include/unotools/localedatawrapper.hxx
index 22cafe581c42..6593e96dcaaa 100644
--- a/include/unotools/localedatawrapper.hxx
+++ b/include/unotools/localedatawrapper.hxx
@@ -80,12 +80,11 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper
     std::shared_ptr< css::i18n::Calendar2 >            xDefaultCalendar;
     std::shared_ptr< css::i18n::Calendar2 >            xSecondaryCalendar;
     css::i18n::LocaleDataItem2                         aLocaleDataItem;
-    css::uno::Sequence< OUString >                     aReservedWordSeq;
     css::uno::Sequence< OUString >                     aDateAcceptancePatterns;
     css::uno::Sequence< sal_Int32 >                    aGrouping;
     // cached items
     OUString                aLocaleItem[css::i18n::LocaleItem::COUNT2];
-    OUString                aReservedWord[css::i18n::reservedWords::COUNT];
+    std::vector<OUString>   aReservedWords;
     OUString                aCurrSymbol;
     OUString                aCurrBankSymbol;
     DateOrder               nDateOrder;
diff --git a/unotools/source/i18n/localedatawrapper.cxx 
b/unotools/source/i18n/localedatawrapper.cxx
index 12a91d363ded..42b8027b3239 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -169,15 +169,12 @@ void LocaleDataWrapper::loadData()
 
     try
     {
-        aReservedWordSeq = xLD->getReservedWord( rMyLocale );
+        aReservedWords = 
comphelper::sequenceToContainer<std::vector<OUString>>(xLD->getReservedWord( 
rMyLocale ));
     }
     catch ( const Exception& )
     {
         TOOLS_WARN_EXCEPTION( "unotools.i18n", "getReservedWord" );
-        aReservedWordSeq = {};
     }
-    for (int i=0; i < css::i18n::reservedWords::COUNT; ++i)
-        aReservedWord[i] = aReservedWordSeq[i];
 
     try
     {
@@ -378,12 +375,13 @@ const OUString& LocaleDataWrapper::getOneLocaleItem( 
sal_Int16 nItem ) const
 
 const OUString& LocaleDataWrapper::getOneReservedWord( sal_Int16 nWord ) const
 {
-    if ( nWord < 0 || nWord >= reservedWords::COUNT )
+    if ( nWord < 0 || nWord >= static_cast<sal_Int16>(aReservedWords.size()) )
     {
         SAL_WARN( "unotools.i18n", "getOneReservedWord: bounds" );
-        nWord = reservedWords::FALSE_WORD;
+        static const OUString EMPTY;
+        return EMPTY;
     }
-    return aReservedWord[nWord];
+    return aReservedWords[nWord];
 }
 
 MeasurementSystem LocaleDataWrapper::mapMeasurementStringToEnum( const 
OUString& rMS ) const

Reply via email to