summaryrefslogtreecommitdiff
path: root/vcl/source/edit
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 /vcl/source/edit
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 'vcl/source/edit')
-rw-r--r--vcl/source/edit/textdoc.hxx7
-rw-r--r--vcl/source/edit/texteng.cxx6
2 files changed, 10 insertions, 3 deletions
diff --git a/vcl/source/edit/textdoc.hxx b/vcl/source/edit/textdoc.hxx
index 1695f9f4c04b..5a6fd869b040 100644
--- a/vcl/source/edit/textdoc.hxx
+++ b/vcl/source/edit/textdoc.hxx
@@ -44,7 +44,12 @@ public:
const TextCharAttrib& GetAttrib( sal_uInt16 n ) const { return *maAttribs[n].get(); }
TextCharAttrib& GetAttrib( sal_uInt16 n ) { return *maAttribs[n].get(); }
- void RemoveAttrib( sal_uInt16 n ) { maAttribs[n].release(); maAttribs.erase( maAttribs.begin() + n ); }
+ std::unique_ptr<TextCharAttrib> RemoveAttrib( sal_uInt16 n )
+ {
+ std::unique_ptr<TextCharAttrib> pReleased = std::move(maAttribs[n]);
+ maAttribs.erase( maAttribs.begin() + n );
+ return pReleased;
+ }
void InsertAttrib( TextCharAttrib* pAttrib );
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index acdb6b74c427..b847d13da856 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -2504,8 +2504,9 @@ void TextEngine::RemoveAttribs( sal_uInt32 nPara, sal_uInt16 nWhich )
}
}
-void TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib )
+std::unique_ptr<TextCharAttrib> TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib )
{
+ std::unique_ptr<TextCharAttrib> pRet;
if ( nPara < mpDoc->GetNodes().size() )
{
TextNode* pNode = mpDoc->GetNodes()[ nPara ];
@@ -2516,7 +2517,7 @@ void TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib )
{
if(&(rAttribs.GetAttrib( nAttr - 1 )) == &rAttrib)
{
- rAttribs.RemoveAttrib( nAttr -1 );
+ pRet = rAttribs.RemoveAttrib( nAttr -1 );
break;
}
}
@@ -2526,6 +2527,7 @@ void TextEngine::RemoveAttrib( sal_uInt32 nPara, const TextCharAttrib& rAttrib )
FormatAndUpdate();
}
}
+ return pRet;
}
void TextEngine::SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_Int32 nStart, sal_Int32 nEnd, bool bIdleFormatAndUpdate )