sw/source/filter/ww8/ww8par.cxx | 9 ++++----- sw/source/filter/ww8/ww8par.hxx | 7 ++++++- 2 files changed, 10 insertions(+), 6 deletions(-)
New commits: commit 14d380f64a0e61ff46203752b6d4208b125db811 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Nov 29 09:18:25 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Nov 29 17:11:19 2021 +0100 ofz#41460 ubsan Bad-cast Change-Id: I0352bce1c699bfa6b7fdd5c3f04e46cc7599ce91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126019 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index ef98c84354a9..cf5f4fe2cb6e 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4712,15 +4712,15 @@ void wwExtraneousParas::insert(SwTextNode *pTextNode) pTextNode->Add(const_cast<TextNodeListener*>(&rListener)); } -void wwExtraneousParas::remove_if_present(SwTextNode *pTextNode) +void wwExtraneousParas::remove_if_present(SwModify* pModify) { auto it = std::find_if(m_aTextNodes.begin(), m_aTextNodes.end(), - [pTextNode](const wwExtraneousParas::TextNodeListener& rEntry) { return rEntry.m_pTextNode == pTextNode; }); + [pModify](const wwExtraneousParas::TextNodeListener& rEntry) { return rEntry.m_pTextNode == pModify; }); if (it == m_aTextNodes.end()) return; SAL_WARN("sw.ww8", "It is unexpected to drop a para scheduled for removal"); const TextNodeListener& rListener = *it; - pTextNode->Remove(const_cast<TextNodeListener*>(&rListener)); + pModify->Remove(const_cast<TextNodeListener*>(&rListener)); m_aTextNodes.erase(it); } @@ -4734,8 +4734,7 @@ void wwExtraneousParas::TextNodeListener::SwClientNotify(const SwModify& rModify // indicates an underlying bug. if (pLegacy->GetWhich() == RES_OBJECTDYING) { - const SwTextNode& rNode(static_cast<SwTextNode const&>(rModify)); - m_pOwner->remove_if_present(const_cast<SwTextNode*>(&rNode)); + m_pOwner->remove_if_present(const_cast<SwModify*>(&rModify)); } } diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 4126763a5512..c646d256c038 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -934,13 +934,18 @@ private: std::set<TextNodeListener> m_aTextNodes; SwDoc& m_rDoc; + void remove_if_present(SwModify* pModify); + wwExtraneousParas(wwExtraneousParas const&) = delete; wwExtraneousParas& operator=(wwExtraneousParas const&) = delete; public: explicit wwExtraneousParas(SwDoc &rDoc) : m_rDoc(rDoc) {} ~wwExtraneousParas() { delete_all_from_doc(); } void insert(SwTextNode *pTextNode); - void remove_if_present(SwTextNode *pTextNode); + void remove_if_present(SwTextNode *pTextNode) + { + remove_if_present(static_cast<SwModify*>(pTextNode)); + } void delete_all_from_doc(); };