summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMatt K <mattkse@gmail.com>2024-02-02 10:35:13 -0600
committerMiklos Vajna <vmiklos@collabora.com>2024-03-14 08:25:09 +0100
commit1b5010bfb745a3a7f0e596b237ab70694484fc33 (patch)
tree3f663ece2575f8f75c4751b54feef7b7a24f8630 /sw
parentc8b8a2c2cb34a1ae0b0aeee0564b39260258f184 (diff)
tdf#154863 Add unit test to cover crash on image move
This reverts commit 332faa63407305852f5044e4bbc41302ccfe46cd. This change adds a CppUnit test that changes the position of an image in an example document which causes a crash if the bug exists. This also adds a delete guard for a SwFrame used to prevent a use-after-free condition. Change-Id: I5cfec75681a5877c007df33c23d9a5e61e4292c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162940 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/objectpositioning/data/tdf154863-img-move-crash.docxbin0 -> 391748 bytes
-rw-r--r--sw/qa/core/objectpositioning/objectpositioning.cxx14
-rw-r--r--sw/source/core/layout/tabfrm.cxx1
3 files changed, 15 insertions, 0 deletions
diff --git a/sw/qa/core/objectpositioning/data/tdf154863-img-move-crash.docx b/sw/qa/core/objectpositioning/data/tdf154863-img-move-crash.docx
new file mode 100644
index 000000000000..ca402edef74d
--- /dev/null
+++ b/sw/qa/core/objectpositioning/data/tdf154863-img-move-crash.docx
Binary files differ
diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx
index bf560cbdaf90..717d63ded052 100644
--- a/sw/qa/core/objectpositioning/objectpositioning.cxx
+++ b/sw/qa/core/objectpositioning/objectpositioning.cxx
@@ -25,6 +25,8 @@
#include <flyfrm.hxx>
#include <frmatr.hxx>
+#include <vcl/scheduler.hxx>
+
namespace
{
/// Covers sw/source/core/objectpositioning/ fixes.
@@ -56,6 +58,18 @@ CPPUNIT_TEST_FIXTURE(Test, testOverlapCrash)
pWrtShell->SplitNode();
}
+CPPUNIT_TEST_FIXTURE(Test, testImgMoveCrash)
+{
+ createSwDoc("tdf154863-img-move-crash.docx");
+ uno::Reference<drawing::XShape> xShape(getShapeByName(u"Image26"), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ xShapeProps->setPropertyValue("VertOrient", uno::Any(static_cast<sal_Int32>(0)));
+ xShapeProps->setPropertyValue("VertOrientPosition", uno::Any(static_cast<sal_Int32>(3000)));
+ Scheduler::ProcessEventsToIdle();
+ // Crash expected before assert if bug exists
+ CPPUNIT_ASSERT(true);
+}
+
CPPUNIT_TEST_FIXTURE(Test, testVertPosFromBottom)
{
// Create a document, insert a shape and position it 1cm above the bottom of the body area.
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index edb10beb35c6..cd44758e574b 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -1754,6 +1754,7 @@ bool SwContentFrame::CalcLowers(SwLayoutFrame & rLay, SwLayoutFrame const& rDont
{
// #i23129#, #i36347# - pass correct page frame to
// the object formatter
+ SwFrameDeleteGuard aDeleteGuard(pCnt);
if ( !SwObjectFormatter::FormatObjsAtFrame( *pCnt,
*(pCnt->FindPageFrame()) ) )
{