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 bb016228172c01b531f36d8bbba3db01605c8053 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Sep 3 13:50:48 2024 +0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Sep 4 10:49:50 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> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172845 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 a7fa0e5ba3f2..ad4057adf300 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -843,6 +843,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf162370) loadAndSave("too_many_styles.odt"); } +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 c0a02761b7d9..71b78bc0914d 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2399,7 +2399,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() );