summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-01-18 14:21:58 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-01-19 06:44:50 +0100
commit13e55cedd2944c41f3f4fe7032cfea1ef9e6015d (patch)
tree20a453102ae6f0b940bf1897f76cb7ebbbb1ccd0
parent4e035a609edb3d8435456e1b9a5fed279821f064 (diff)
tdf#115065: nullptr dereference
Change-Id: Iafaaafdabf9fb7947fa0b03cd38d3b4a567a41b9 Reviewed-on: https://gerrit.libreoffice.org/48110 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf115065.odtbin0 -> 9972 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx27
-rw-r--r--sw/source/core/crsr/swcrsr.cxx4
3 files changed, 29 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf115065.odt b/sw/qa/extras/uiwriter/data/tdf115065.odt
new file mode 100644
index 000000000000..86fc28aaf686
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf115065.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 7e3a0d54e533..f32c512d84de 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -297,6 +297,7 @@ public:
void testTdf113481();
void testTdf115013();
void testTdf114536();
+ void testTdf115065();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -473,6 +474,7 @@ public:
CPPUNIT_TEST(testTdf113481);
CPPUNIT_TEST(testTdf115013);
CPPUNIT_TEST(testTdf114536);
+ CPPUNIT_TEST(testTdf115065);
CPPUNIT_TEST_SUITE_END();
private:
@@ -5805,6 +5807,31 @@ void SwUiWriterTest::testTdf115013()
CPPUNIT_ASSERT_EQUAL(sColumnName, sColumn);
}
+void SwUiWriterTest::testTdf115065()
+{
+ // In the document, the tables have table style assigned
+ // Source table (first one) has two rows;
+ // destination (second one) has only one row
+ SwDoc* pDoc = createDoc("tdf115065.odt");
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ pWrtShell->GotoTable("Table2");
+ SwRect aRect = pWrtShell->GetCurrFrame()->getFrameArea();
+ // Destination point is the middle of the first cell of second table
+ Point ptTo = Point(aRect.Left() + aRect.Width() / 2, aRect.Top() + aRect.Height() / 2);
+
+ pWrtShell->GotoTable("Table1");
+ aRect = pWrtShell->GetCurrFrame()->getFrameArea();
+ // Source point is the middle of the first cell of first table
+ Point ptFrom = Point(aRect.Left() + aRect.Width() / 2, aRect.Top() + aRect.Height() / 2);
+
+ pWrtShell->SelTableCol();
+ // The copy operation (or closing document after that) segfaulted
+ pWrtShell->Copy(pWrtShell, ptFrom, ptTo);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 973880821359..4705f5c625ac 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -2265,8 +2265,8 @@ void SwTableCursor::DeleteBox(size_t const nPos)
bool SwTableCursor::NewTableSelection()
{
bool bRet = false;
- const SwNode *pStart = GetContentNode()->FindTableBoxStartNode();
- const SwNode *pEnd = GetContentNode(false)->FindTableBoxStartNode();
+ const SwNode *pStart = GetNode().FindTableBoxStartNode();
+ const SwNode *pEnd = GetNode(false).FindTableBoxStartNode();
if( pStart && pEnd )
{
const SwTableNode *pTableNode = pStart->FindTableNode();