sw/qa/extras/odfexport/data/tdf163575.docx |binary
 sw/qa/extras/odfexport/odfexport2.cxx      |    6 ++++++
 sw/source/core/text/pormulti.cxx           |    2 ++
 3 files changed, 8 insertions(+)

New commits:
commit db35d917befec21fffb168ab9e0e87191b2d02d1
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Oct 22 16:59:24 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Mon Oct 28 14:03:57 2024 +0100

    tdf#163575 sw smart justify: fix size resolution for SwBidiPortion
    
    Negative space sizes (i.e. shrunk lines at image wrapping) stored
    over LONG_MAX/2, and these values had no resolution in SwBidiPortion,
    causing crash/assert in conversion of DOCX document containing e.g.
    Arabic text wrapping around images.
    
    Note: apply the resolution in SwDoubleLinePortion, too.
    
    Regression since commit 1fb6de02709a5f420f21ebd683915da50ce0d198
    "tdf#163149 sw smart justify: fix line shrinking at image wrapping".
    
    Change-Id: I6e45592c4eed247871d35e1f02fd5a038baddf85
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175419
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: Jenkins
    (cherry picked from commit 270c96e12c4a14c4f9e130d15310843da3a6af68)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175433
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175650
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sw/qa/extras/odfexport/data/tdf163575.docx 
b/sw/qa/extras/odfexport/data/tdf163575.docx
new file mode 100644
index 000000000000..8d6c8f17fe69
Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf163575.docx differ
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx 
b/sw/qa/extras/odfexport/odfexport2.cxx
index a2acec11393f..71345908df4e 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -366,6 +366,12 @@ CPPUNIT_TEST_FIXTURE(Test, tdf99631)
     assertXPathContent(pXmlDoc2, 
"//config:config-item[@config:name='VisibleAreaHeight']"_ostr, "1355");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, tdf163575)
+{
+    // crashes/assert at export time
+    loadAndReload("tdf163575.docx");
+}
+
 CPPUNIT_TEST_FIXTURE(Test, tdf145871)
 {
     loadAndReload("tdf145871.odt");
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 7771ab9b5e8f..fe26c73af69f 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -221,6 +221,7 @@ SwBidiPortion::SwBidiPortion(TextFrameIndex const nEnd, 
sal_uInt8 nLv)
 
 SwTwips SwBidiPortion::CalcSpacing( tools::Long nSpaceAdd, const 
SwTextSizeInfo& rInf ) const
 {
+    nSpaceAdd = nSpaceAdd > LONG_MAX/2 ? LONG_MAX/2 - nSpaceAdd : nSpaceAdd;
     return HasTabulator() ? 0 : sal_Int32(GetSpaceCnt(rInf)) * nSpaceAdd / 
SPACING_PRECISION_FACTOR;
 }
 
@@ -507,6 +508,7 @@ void SwDoubleLinePortion::CalcBlanks( SwTextFormatInfo 
&rInf )
 
 SwTwips SwDoubleLinePortion::CalcSpacing( tools::Long nSpaceAdd, const 
SwTextSizeInfo & ) const
 {
+    nSpaceAdd = nSpaceAdd > LONG_MAX/2 ? LONG_MAX/2 - nSpaceAdd : nSpaceAdd;
     return HasTabulator() ? 0 : sal_Int32(GetSpaceCnt()) * nSpaceAdd / 
SPACING_PRECISION_FACTOR;
 }
 

Reply via email to