Skip to content

Commit

Permalink
Do not cache instances of com.sun.star.i18n.Transliteration.l10n
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ardovm committed Nov 14, 2023
1 parent b117abe commit f0439ff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
9 changes: 0 additions & 9 deletions main/i18npool/inc/transliterationImpl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<com::sun::star::i18n::XExtendedTransliteration> & body, const com::sun::star::lang::Locale& rLocale)
throw(com::sun::star::uno::RuntimeException);
Expand Down
13 changes: 0 additions & 13 deletions main/i18npool/source/transliteration/transliterationImpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ static struct TMlist {
{(TransliterationModules)0, (TransliterationModulesNew)0, NULL}
};

TransliterationImpl::TransBody TransliterationImpl::lastTransBody;

// Constructor/Destructor
TransliterationImpl::TransliterationImpl(const Reference <XMultiServiceFactory>& xMSF) : xSMgr(xMSF)
{
Expand Down Expand Up @@ -591,15 +589,6 @@ TransliterationImpl::clear()
void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& 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)));
Expand All @@ -616,8 +605,6 @@ void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTrans
a = xI->queryInterface(::getCppuType((
const Reference<XExtendedTransliteration>*)0));
a >>= body;
lastTransBody.Name = implName;
lastTransBody.Body = body;
return;
}
}
Expand Down

0 comments on commit f0439ff

Please sign in to comment.