sw/qa/core/data/ww5/pass/ooo37322-1-WW2.doc |binary
 sw/source/filter/ww8/ww8par.cxx             |    9 +++++++++
 2 files changed, 9 insertions(+)

New commits:
commit c1cd505c67a53a0a27589889b34641612d10946d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Aug 18 16:57:18 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Aug 18 21:21:26 2021 +0200

    ofz#37322 Bad-cast
    
    use a SwUnoCursor for the LastAnchorPos around here, this is similar to
    ofz#9858 Bad-cast
    
    Change-Id: I194a39ae13c382740b0ba8145dcc33fb2107105d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120679
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/qa/core/data/ww5/pass/ooo37322-1-WW2.doc 
b/sw/qa/core/data/ww5/pass/ooo37322-1-WW2.doc
new file mode 100644
index 000000000000..fd64eeed2963
Binary files /dev/null and b/sw/qa/core/data/ww5/pass/ooo37322-1-WW2.doc differ
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9c0862f5a9c6..09065cc441c3 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2067,8 +2067,17 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
     pRdr->m_xCtrlStck = std::move(mxOldStck);
 
     pRdr->m_xRedlineStack->closeall(*pRdr->m_pPaM->GetPoint());
+
+    // ofz#37322 drop m_pLastAnchorPos during RedlineStack dtor and restore it 
afterwards to the same
+    // place, or somewhere close if that place got destroyed
+    std::shared_ptr<SwUnoCursor> xLastAnchorCursor(pRdr->m_pLastAnchorPos ? 
pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_pLastAnchorPos) : nullptr);
+    pRdr->m_pLastAnchorPos.reset();
+
     pRdr->m_xRedlineStack = std::move(mxOldRedlines);
 
+    if (xLastAnchorCursor)
+        pRdr->m_pLastAnchorPos.reset(new 
SwPosition(*xLastAnchorCursor->GetPoint()));
+
     pRdr->DeleteAnchorStack();
     pRdr->m_xAnchorStck = std::move(mxOldAnchorStck);
 

Reply via email to