sw/qa/extras/ooxmlexport/data/tdf162746.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 6 ++++++ sw/source/core/text/itrform2.cxx | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-)
New commits: commit 74533c1f1d5e8e48a65d33bef236f1382d32aa06 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Sep 3 13:50:48 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Sep 3 17:28:35 2024 +0200 tdf#162746: sanitize width in SwTextFormatter::FeedInf Since commit 7e9c23894bd45e015accf26ae0a77035b7eed452 (tdf#161368: use SwTwips for twip sizes, instead of sal_uInt16), the result of rInf.Right() - GetLeftMargin() is not cast to an unsigned type, so may happen to be a negative value. Make sure it's not negative; this doesn't fix the layout of this document (it still opens with table having wrong width, as before the mentioned commit), just avoids the infinite layout loop. Change-Id: I4930c8718d5fd09064ae0febd9b5adbdb0e2cd5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172789 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf162746.docx b/sw/qa/extras/ooxmlexport/data/tdf162746.docx new file mode 100644 index 000000000000..6143196a13cb Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf162746.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index ee67ec61fe5e..884ddc991585 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -1177,6 +1177,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf61309) CPPUNIT_ASSERT_EQUAL(1, getPages()); } +CPPUNIT_TEST_FIXTURE(Test, testTdf162746) +{ + // Without the fix in place this hangs (and eventually OOMs) on opening + loadAndSave("tdf162746.docx"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 89a2744d0bd9..4b3778dd6ed4 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2403,7 +2403,7 @@ void SwTextFormatter::FeedInf( SwTextFormatInfo &rInf ) const rInf.LeftMargin(GetLeftMargin()); rInf.RealWidth(rInf.Right() - GetLeftMargin()); - rInf.Width( rInf.RealWidth() ); + rInf.Width(std::max(rInf.RealWidth(), SwTwips(0))); if( const_cast<SwTextFormatter*>(this)->GetRedln() ) { const_cast<SwTextFormatter*>(this)->GetRedln()->Clear( const_cast<SwTextFormatter*>(this)->GetFnt() );