Kaydet (Commit) c0f51bdf authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_2: fix use-after-free of SwFont

SwTextSizeInfo::m_pFnt may be an alias of either SwAttrIter or
SwAttrHandler's SwFont members; keep these alive if they exist when
re-initialising from SwAttrIter::Seek().

Change-Id: I8fcbcf3aa339dfc6fa33b5439facadc6034c8cf5
üst dc4edcc6
......@@ -401,8 +401,17 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
}
// It is possible, that Init is called more than once, e.g., in a
// SwTextFrame::FormatOnceMore situation.
m_pFnt.reset( new SwFont(rFnt) );
// SwTextFrame::FormatOnceMore situation or (since sw_redlinehide)
// from SwAttrIter::Seek(); in the latter case SwTextSizeInfo::m_pFnt
// is an alias of m_pFnt so it must not be deleted!
if (m_pFnt)
{
*m_pFnt = rFnt;
}
else
{
m_pFnt.reset(new SwFont(rFnt));
}
}
void SwAttrHandler::Reset( )
......
......@@ -135,8 +135,18 @@ void SwAttrIter::InitFontAndAttrHandler(SwTextNode const& rTextNode,
{
// Build a font matching the default paragraph style:
SwFontAccess aFontAccess( &rTextNode.GetAnyFormatColl(), m_pViewShell );
delete m_pFont;
m_pFont = new SwFont( aFontAccess.Get()->GetFont() );
// It is possible that Init is called more than once, e.g., in a
// SwTextFrame::FormatOnceMore situation or (since sw_redlinehide)
// from SwAttrIter::Seek(); in the latter case SwTextSizeInfo::m_pFnt
// is an alias of m_pFont so it must not be deleted!
if (m_pFont)
{
*m_pFont = aFontAccess.Get()->GetFont();
}
else
{
m_pFont = new SwFont( aFontAccess.Get()->GetFont() );
}
// set font to vertical if frame layout is vertical
// if it's a re-init, the vert flag never changes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment