diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-29 09:18:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-29 17:11:19 +0100 |
commit | 14d380f64a0e61ff46203752b6d4208b125db811 (patch) | |
tree | 0f94edfa56ae07245c7b0a321626d8627f10f379 /sw/source/filter | |
parent | a4691c7d5eb494c242305936428086940f90d83a (diff) |
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 <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 7 |
2 files changed, 10 insertions, 6 deletions
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(); }; |