diff --git a/sw/qa/extras/ooxmlimport/data/file_crash.docx b/sw/qa/extras/ooxmlimport/data/file_crash.docx new file mode 100644 index 000000000000..7a233aba5c47 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/file_crash.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index ea6f8e609b86..8f6e9311c7f8 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1555,6 +1555,11 @@ DECLARE_OOXMLIMPORT_TEST(testFdo70457, "fdo70457.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(4500), getProperty(getShape(1), "RotateAngle")); } +DECLARE_OOXMLIMPORT_TEST(testLOCrash,"file_crash.docx") +{ + //The problem was libreoffice crash while opening the file. + getParagraph(1,"Contents"); +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index e28617df0efe..bece3856bdf4 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -1616,7 +1616,7 @@ void SwTOXBaseSection::GenerateText( sal_uInt16 nArrayIdx, case TOKEN_ENTRY_TEXT: { - SwIndex aIdx( pTOXNd, rTxt.getLength() ); + SwIndex aIdx( pTOXNd, std::min(pTOXNd->GetTxt().getLength(),rTxt.getLength()) ); rBase.FillText( *pTOXNd, aIdx ); rTxt = lcl_RemoveLineBreaks(rTxt); }