summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-09-28 00:18:05 +0200
committerMichael Stahl <mstahl@redhat.com>2017-09-28 13:10:58 +0200
commit19910c461230f70bb9e98ad44db3525f0d755724 (patch)
tree7dbb8eb1769cca940375cee2ff26e8a595e1d8e6 /cui
parent4fca2ef76a6dfe6c74ada71ab4806dc4ad568b82 (diff)
tdf#112658: fix leak when calling TextEngine::SetAttrib
TextCharAttribList::RemoveAttrib lets a dangling pointer when release unique_ptr obj maAttribs[n] So retrieve a unique_ptr from the different layers until SentenceEditWindow_Impl::ChangeMarkedWord (SpellDialog.cxx). Change-Id: I734909dce86ec28d69c09b2a8c0fc4a6941f422a Reviewed-on: https://gerrit.libreoffice.org/42881 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/SpellDialog.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 82c91910d130..57358d89ad3a 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -1643,11 +1643,14 @@ void SentenceEditWindow_Impl::ChangeMarkedWord(const OUString& rNewWord, Languag
ExtTextEngine* pTextEngine = GetTextEngine();
pTextEngine->UndoActionStart();
const TextCharAttrib* pErrorAttrib = pTextEngine->FindCharAttrib( TextPaM(0, m_nErrorStart), TEXTATTR_SPELL_ERROR );
+ std::unique_ptr<TextCharAttrib> pReleasedErrorAttrib;
+ std::unique_ptr<TextCharAttrib> pReleasedLangAttrib;
+ std::unique_ptr<TextCharAttrib> pReleasedBackAttrib;
DBG_ASSERT(pErrorAttrib, "no error attribute found");
const SpellErrorDescription* pSpellErrorDescription = nullptr;
if(pErrorAttrib)
{
- pTextEngine->RemoveAttrib(0, *pErrorAttrib);
+ pReleasedErrorAttrib = pTextEngine->RemoveAttrib(0, *pErrorAttrib);
pSpellErrorDescription = &static_cast<const SpellErrorAttrib&>(pErrorAttrib->GetAttr()).GetErrorDescription();
}
const TextCharAttrib* pBackAttrib = pTextEngine->FindCharAttrib( TextPaM(0, m_nErrorStart), TEXTATTR_SPELL_BACKGROUND );
@@ -1666,7 +1669,7 @@ void SentenceEditWindow_Impl::ChangeMarkedWord(const OUString& rNewWord, Languag
nTextLen)
{
SpellLanguageAttrib aNewLangAttrib( static_cast<const SpellLanguageAttrib&>(pLangAttrib->GetAttr()).GetLanguage());
- pTextEngine->RemoveAttrib(0, *pLangAttrib);
+ pReleasedLangAttrib = pTextEngine->RemoveAttrib(0, *pLangAttrib);
pTextEngine->SetAttrib( aNewLangAttrib, 0, m_nErrorEnd + nDiffLen, nTextLen );
}
}
@@ -1675,7 +1678,7 @@ void SentenceEditWindow_Impl::ChangeMarkedWord(const OUString& rNewWord, Languag
{
std::unique_ptr<TextAttrib> pNewBackground(pBackAttrib->GetAttr().Clone());
const sal_Int32 nStart = pBackAttrib->GetStart();
- pTextEngine->RemoveAttrib(0, *pBackAttrib);
+ pReleasedBackAttrib = pTextEngine->RemoveAttrib(0, *pBackAttrib);
pTextEngine->SetAttrib(*pNewBackground, 0, nStart, m_nErrorStart);
}
pTextEngine->SetModified(true);