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

ofz#4872 Null-dereference READ

we're going to need a bigger boat

Change-Id: Ie4ee3ae1ac9f906ca3faec412bbafc0c6a911aaf
Reviewed-on: https://gerrit.libreoffice.org/47269Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5b7ec49f
......@@ -4981,6 +4981,48 @@ HTMLTableOptions::HTMLTableOptions( const HTMLOptions& rOptions,
}
}
namespace
{
class FrameDeleteWatch : public SwClient
{
SwFrameFormat* m_pObjectFormat;
bool m_bDeleted;
public:
FrameDeleteWatch(SwFrameFormat* pObjectFormat)
: m_pObjectFormat(pObjectFormat)
, m_bDeleted(false)
{
if (m_pObjectFormat)
m_pObjectFormat->Add(this);
}
virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) override
{
SwClient::SwClientNotify(rModify, rHint);
if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
{
if (pDrawFrameFormatHint->m_eId == sw::DrawFrameFormatHintId::DYING)
{
m_pObjectFormat->Remove(this);
m_bDeleted = true;
}
}
}
bool WasDeleted() const
{
return m_bDeleted;
}
virtual ~FrameDeleteWatch() override
{
if (!m_bDeleted && m_pObjectFormat)
m_pObjectFormat->Remove(this);
}
};
}
std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
bool bIsParentHead,
bool bHasParentSection,
......@@ -5250,20 +5292,18 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
//if section to be deleted contains a pending m_pMarquee, it will be deleted
//so clear m_pMarquee pointer if that's the case
SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr;
if (pObjectFormat)
{
const SwFormatAnchor& rAnch = pObjectFormat->GetAnchor();
if (const SwPosition* pPos = rAnch.GetContentAnchor())
{
SwNodeIndex aMarqueeNodeIndex(pPos->nNode);
SwNodeIndex aSttIdx(*pSttNd), aEndIdx(*pSttNd->EndOfSectionNode());
if (aMarqueeNodeIndex >= aSttIdx && aMarqueeNodeIndex <= aEndIdx)
m_pMarquee = nullptr;
}
}
FrameDeleteWatch aWatch(pObjectFormat);
m_xDoc->getIDocumentContentOperations().DeleteSection(pSttNd);
xCurTable->SetCaption( nullptr, false );
if (pObjectFormat)
{
if (aWatch.WasDeleted())
m_pMarquee = nullptr;
else
pObjectFormat->Remove(&aWatch);
}
}
}
......
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