sw/qa/extras/uiwriter/data/tdf143320.odt |binary
 sw/qa/extras/uiwriter/uiwriter4.cxx      |   37 +++++++++++++++++++++++++++++++
 sw/source/core/frmedt/fefly1.cxx         |    4 +--
 3 files changed, 39 insertions(+), 2 deletions(-)

New commits:
commit 17b2f3d96fb21dcfc2fb8e54ca9670a8c58840f1
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Jul 14 14:41:24 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 30 21:14:00 2024 +0200

    tdf#143320, tdf#143387: sw_uiwriter4: Add unittest
    
    Change-Id: I45aaa88c8ed70f3eebd30dfcd29edc4e1e4a5694
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118908
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/data/tdf143320.odt 
b/sw/qa/extras/uiwriter/data/tdf143320.odt
new file mode 100644
index 000000000000..b7aef0c34bb0
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf143320.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx 
b/sw/qa/extras/uiwriter/uiwriter4.cxx
index 7757ceb9701e..c361ddfb80e0 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -2572,6 +2572,43 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf142157)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf143320)
+{
+    createSwDoc("tdf143320.odt");
+    SwDoc* pDoc = getSwDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("x"));
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    // Create a new document
+    createSwDoc();
+    pDoc = getSwDoc();
+    pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("x"));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString());
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    CPPUNIT_ASSERT_EQUAL(1, getPages());
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("x"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit acad40220d21e73b5fb699404ae1a2dc29218faa
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Apr 30 10:07:23 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 30 21:13:52 2024 +0200

    Fix UBSan failure (part 2)
    
    Introduced by 495b5db74f0db59395ff68bacc8d8ca67595b66e
    "sw: check GetUserCall"
    
    https: //gerrit.libreoffice.org/c/core/+/166824/comments/8db24a41_2f4e7e4e
    Change-Id: Ib6f981aa3055f0d37d0b83e3284842d310fe6ef0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166913
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 280166ed888b..eca71843557b 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -386,7 +386,7 @@ const SwFrameFormat* SwFEShell::IsFlyInFly()
         return nullptr;
 
     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
-    SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
+    SwContact* pContact = GetUserCall( pObj );
     if (!pContact)
         return nullptr;
 
@@ -400,7 +400,7 @@ const SwFrameFormat* SwFEShell::IsFlyInFly()
         }
         else
         {
-            pFly = pContact->GetAnchorFrame(pObj);
+            pFly = static_cast<SwDrawContact*>(pContact)->GetAnchorFrame(pObj);
         }
 
         OSL_ENSURE( pFly, "IsFlyInFly: Where's my anchor?" );

Reply via email to