sw/qa/extras/uiwriter/data/forum-mso-en-13192-min.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx                     |   43 +++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit 05c423c6a9ebdc432053194431c12bf3bdaf8546
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 15 17:58:19 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Dec 16 13:26:31 2022 +0000

    tdf#149548 sw: add unit test
    
    Change-Id: Ibb4eadc15f539ee2d4f030c6366c9abd92bc3823
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144249
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 4cc101bfc362d4aea1ecc9136b20b73910fa0041)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144298

diff --git a/sw/qa/extras/uiwriter/data/forum-mso-en-13192-min.docx 
b/sw/qa/extras/uiwriter/data/forum-mso-en-13192-min.docx
new file mode 100644
index 000000000000..0d44a3c2d15c
Binary files /dev/null and 
b/sw/qa/extras/uiwriter/data/forum-mso-en-13192-min.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index bc539e810c90..5b35941729a1 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -283,6 +283,49 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149595)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf149548)
+{
+    createSwDoc("forum-mso-en-13192-min.docx");
+    SwDoc* pDoc = getSwDoc();
+
+    for (SwRangeRedline const*const pRedline : 
pDoc->getIDocumentRedlineAccess().GetRedlineTable())
+    {
+        if (pRedline->GetType() == RedlineType::Delete)
+        {
+            int nLevel(0);
+            for (SwNodeIndex index = pRedline->Start()->nNode; index <= 
pRedline->End()->nNode; ++index)
+            {
+                switch (index.GetNode().GetNodeType())
+                {
+                    case SwNodeType::Start:
+                    case SwNodeType::Table:
+                    case SwNodeType::Section:
+                        ++nLevel;
+                        break;
+                    case SwNodeType::End:
+                        CPPUNIT_ASSERT_MESSAGE("bad overlapping redline", 
nLevel != 0);
+                        --nLevel;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            CPPUNIT_ASSERT_EQUAL_MESSAGE("bad overlapping redline", int(0), 
nLevel);
+        }
+    }
+
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+    rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+    pTransfer->Copy();
+
+    TransferableDataHelper aHelper(pTransfer);
+    // this was a use-after-free on nodes deleted by Copy
+    SwTransferable::Paste(*pWrtShell, aHelper);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testBookmarkCopy)
 {
     createSwDoc();

Reply via email to