From f0439fff86115a6959e104fea345d175528afdf0 Mon Sep 17 00:00:00 2001 From: Arrigo Marchiori Date: Sun, 19 Feb 2023 09:45:46 +0100 Subject: [PATCH] Do not cache instances of com.sun.star.i18n.Transliteration.l10n Such instances may be modified by the callers. If objects are cached, one caller may see its instance unexpectedly modified by another caller. This happened with Transliteration_caseignore instances in bug #126680. --- main/i18npool/inc/transliterationImpl.hxx | 9 --------- .../source/transliteration/transliterationImpl.cxx | 13 ------------- 2 files changed, 22 deletions(-) diff --git a/main/i18npool/inc/transliterationImpl.hxx b/main/i18npool/inc/transliterationImpl.hxx index 5cd3c7b2bd..74b827b873 100644 --- a/main/i18npool/inc/transliterationImpl.hxx +++ b/main/i18npool/inc/transliterationImpl.hxx @@ -121,15 +121,6 @@ private: com::sun::star::uno::Reference< XLocaleData > localedata; com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > caseignore; - /** structure to cache the last transliteration body used. */ - struct TransBody - { - ::osl::Mutex mutex; - ::rtl::OUString Name; - ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedTransliteration > Body; - }; - static TransBody lastTransBody; - virtual sal_Bool SAL_CALL loadModuleByName( const rtl::OUString& implName, com::sun::star::uno::Reference & body, const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException); diff --git a/main/i18npool/source/transliteration/transliterationImpl.cxx b/main/i18npool/source/transliteration/transliterationImpl.cxx index 8b68415484..2141fd5859 100644 --- a/main/i18npool/source/transliteration/transliterationImpl.cxx +++ b/main/i18npool/source/transliteration/transliterationImpl.cxx @@ -144,8 +144,6 @@ static struct TMlist { {(TransliterationModules)0, (TransliterationModulesNew)0, NULL} }; -TransliterationImpl::TransBody TransliterationImpl::lastTransBody; - // Constructor/Destructor TransliterationImpl::TransliterationImpl(const Reference & xMSF) : xSMgr(xMSF) { @@ -591,15 +589,6 @@ TransliterationImpl::clear() void TransliterationImpl::loadBody( OUString &implName, Reference& body ) throw (RuntimeException) { - ::osl::MutexGuard guard(lastTransBody.mutex); - - if (implName.equals(lastTransBody.Name)) - { - // Use the cached body instead of going through the expensive looping again. - body = lastTransBody.Body; - return; - } - Reference< XContentEnumerationAccess > xEnumAccess( xSMgr, UNO_QUERY ); Reference< XEnumeration > xEnum(xEnumAccess->createContentEnumeration( OUString::createFromAscii(TRLT_SERVICELNAME_L10N))); @@ -616,8 +605,6 @@ void TransliterationImpl::loadBody( OUString &implName, ReferencequeryInterface(::getCppuType(( const Reference*)0)); a >>= body; - lastTransBody.Name = implName; - lastTransBody.Body = body; return; } }