Kaydet (Commit) ee8c90c4 authored tarafından Caolán McNamara's avatar Caolán McNamara

ubsan: use after free

Change-Id: I1a3396d434f6cc5bb615bcb2fe06a819bc11c013
Reviewed-on: https://gerrit.libreoffice.org/71256
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 40f257e6
......@@ -1237,19 +1237,8 @@ public:
//Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete
//it in e.g. SwSectionFrame::MergeNext etc because we will need it
//again after the SwFrameDeleteGuard dtor
explicit SwFrameDeleteGuard(SwFrame* pFrame)
: m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ?
pFrame : nullptr)
{
if (m_pForbidFrame)
m_pForbidFrame->ForbidDelete();
}
~SwFrameDeleteGuard()
{
if (m_pForbidFrame)
m_pForbidFrame->AllowDelete();
}
explicit SwFrameDeleteGuard(SwFrame* pFrame);
~SwFrameDeleteGuard();
};
typedef long (SwFrame:: *SwFrameGet)() const;
......
......@@ -468,6 +468,33 @@ void SwTextFrame::RegisterToNode(SwTextNode & rNode, bool const isForceNodeAsFir
}
}
//Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete
//it in e.g. SwSectionFrame::MergeNext etc because we will need it
//again after the SwFrameDeleteGuard dtor
SwFrameDeleteGuard::SwFrameDeleteGuard(SwFrame* pFrame)
: m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ? pFrame : nullptr)
{
if (m_pForbidFrame)
{
m_pForbidFrame->ForbidDelete();
}
}
SwFrameDeleteGuard::~SwFrameDeleteGuard()
{
if (m_pForbidFrame)
{
const bool bLogicErrorThrown = !m_pForbidFrame->IsDeleteForbidden();
if (bLogicErrorThrown)
{
// see testForcepoint80
SwFrame::DestroyFrame(m_pForbidFrame);
return;
}
m_pForbidFrame->AllowDelete();
}
}
void SwLayoutFrame::DestroyImpl()
{
while (!m_VertPosOrientFramesFor.empty())
......@@ -527,7 +554,8 @@ void SwLayoutFrame::DestroyImpl()
pFrame->AllowDelete();
bFatalError = true;
}
SwFrame::DestroyFrame(pFrame);
else
SwFrame::DestroyFrame(pFrame);
pFrame = m_pLower;
}
......
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