sw/source/core/text/portxt.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c5ea665b417551368e5048f5aaee00ad09b2065f
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue Jun 10 08:48:15 2025 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jun 10 11:10:40 2025 +0200

    Avoid float-divide-by-zero
    
    ...during CppunitTest_sw_uiwriter6
    
    > /sw/source/core/text/portxt.cxx:496:54: runtime error: division by zero
    >     #0 0x7f3faa259544 in SwTextPortion::Format_(SwTextFormatInfo&) 
/sw/source/core/text/portxt.cxx:496:54
    >     #1 0x7f3faa264f98 in SwTextPortion::Format(SwTextFormatInfo&) 
/sw/source/core/text/portxt.cxx:705:12
    >     #2 0x7f3fa9f699c2 in 
SwTextFormatter::BuildPortions(SwTextFormatInfo&) 
/sw/source/core/text/itrform2.cxx:615:27
    >     #3 0x7f3fa9f9e70a in 
SwTextFormatter::FormatLine(o3tl::strong_int<int, Tag_TextFrameIndex>) 
/sw/source/core/text/itrform2.cxx:2078:9
    >     #4 0x7f3fa9d3b4e8 in SwTextFrame::FormatLine(SwTextFormatter&, bool) 
/sw/source/core/text/frmform.cxx:1460:44
    >     #5 0x7f3fa9d4addd in SwTextFrame::Format_(SwTextFormatter&, 
SwTextFormatInfo&, bool) /sw/source/core/text/frmform.cxx:1827:23
    >     #6 0x7f3fa9d508a7 in SwTextFrame::FormatImpl(OutputDevice*, 
SwParaPortion*, std::__debug::vector<SwAnchoredObject*, 
std::allocator<SwAnchoredObject*> >&) /sw/source/core/text/frmform.cxx:2018:5
    >     #7 0x7f3fa9d5712d in SwTextFrame::Format(OutputDevice*, SwBorderAttrs 
const*) /sw/source/core/text/frmform.cxx:2270:17
    >     #8 0x7f3fa8dd35a4 in SwContentFrame::MakeAll(OutputDevice*) 
/sw/source/core/layout/calcmove.cxx:1624:17
    >     #9 0x7f3fa8da3621 in SwFrame::OptPrepareMake() 
/sw/source/core/layout/calcmove.cxx:420:9
    >     #10 0x7f3fa91cc5d0 in SwFrame::OptCalc() const 
/sw/source/core/inc/frame.hxx:1123:37
    >     #11 0x7f3fa91afa95 in SwLayAction::FormatContent_(SwContentFrame 
const*, SwPageFrame const*) /sw/source/core/layout/layact.cxx:1997:19
    >     #12 0x7f3fa919afba in SwLayAction::FormatContent(SwPageFrame*) 
/sw/source/core/layout/layact.cxx:1818:13
    >     #13 0x7f3fa917f171 in SwLayAction::InternalAction(OutputDevice*) 
/sw/source/core/layout/layact.cxx:622:31
    >     #14 0x7f3fa91795e7 in SwLayAction::Action(OutputDevice*) 
/sw/source/core/layout/layact.cxx:397:5
    >     #15 0x7f3fabd82d01 in SwViewShell::ImplEndAction(bool) 
/sw/source/core/view/viewsh.cxx:348:17
    >     #16 0x7f3fabd80ce1 in SwViewShell::EndAction(bool) 
/sw/source/core/view/viewsh.cxx:295:9
    >     #17 0x7f3fa61c1184 in SwCursorShell::EndAction(bool) 
/sw/source/core/crsr/crsrsh.cxx:266:18
    >     #18 0x7f3fabd80671 in SwViewShell::EndAllAction() 
/sw/source/core/view/viewsh.cxx:282:23
    >     #19 0x7f3fa8585747 in 
SwEditShell::TransliterateText(TransliterationFlags) 
/sw/source/core/edit/editsh.cxx:1072:5
    >     #20 0x7f3fadf22817 in 
SwTextShell::ExecRotateTransliteration(SfxRequest&) 
/sw/source/uibase/shells/textsh.cxx:901:17
    >     #21 0x7f3fadf21e64 in 
SfxStubSwTextShellExecRotateTransliteration(SfxShell*, SfxRequest&) 
/workdir/SdiTarget/sw/sdi/swslots.hxx:3235:1
    >     #22 0x7f3fcb7fe85c in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot 
const&, SfxRequest&, bool) /sfx2/source/control/dispatch.cxx:256:9
    >     #23 0x7f3fcb814465 in SfxDispatcher::Execute_(SfxShell&, SfxSlot 
const&, SfxRequest&, SfxCallMode) /sfx2/source/control/dispatch.cxx:755:9
    >     #24 0x7f3fcb79a417 in SfxBindings::Execute_Impl(SfxRequest&, SfxSlot 
const*, SfxShell*) /sfx2/source/control/bindings.cxx:1046:22
    >     #25 0x7f3fcbbfda37 in 
SfxDispatchController_Impl::dispatch(com::sun::star::util::URL const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, 
com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> 
const&) /sfx2/source/control/unoctitm.cxx:736:53
    >     #26 0x7f3fcbc003e1 in 
SfxOfficeDispatch::dispatchWithNotification(com::sun::star::util::URL const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, 
com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> 
const&) /sfx2/source/control/unoctitm.cxx:271:16
    >     #27 0x7f3f7bfaedc6 in 
framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatch>
 const&, com::sun::star::util::URL const&, bool, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
/framework/source/services/dispatchhelper.cxx:164:30
    >     #28 0x7f3f7bfadc9b in 
framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider>
 const&, rtl::OUString const&, rtl::OUString const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
/framework/source/services/dispatchhelper.cxx:121:16
    >     #29 0x7f3f7bfaf674 in non-virtual thunk to 
framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider>
 const&, rtl::OUString const&, rtl::OUString const&, int, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
/framework/source/services/dispatchhelper.cxx
    >     #30 0x7f3f9c13c6ac in 
unotest::MacrosTest::dispatchCommand(com::sun::star::uno::Reference<com::sun::star::lang::XComponent>
 const&, rtl::OUString const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
/unotest/source/cpp/macros_test.cxx:96:33
    >     #31 0x7f3fd95dba24 in testTdf157937::TestBody() 
/sw/qa/extras/uiwriter/uiwriter6.cxx:685:5
    
    (<https://ci.libreoffice.org/job/lo_ubsan/3587/>) after
    529755f0919217a84a12daad0fddfddd1124f0e9 "tdf#166113 sw smart justify: 
adjust
    algorithm for interoperability", assuming that "0" was rather meant to be 
"1"
    
    Change-Id: Ife289c280ca3ba9c05eea315b82ffebec8e84845
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186316
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 36ad3e50f5a3..ddc063709210 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -492,7 +492,7 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf )
                         float fExpansionWeight = static_cast<float>(1/1.7);
                         float fSpaceShrunk = nSpacesInLineShrink > 0
                                 ? (rInf.GetLineWidth() - (rInf.GetBreakWidth() 
- nSpacesInLineShrink * nSpaceWidth/10.0))/nSpacesInLineShrink
-                                : 0;
+                                : 1;
                         float z0 = (nSpaceWidth/10.0)/fSpaceShrunk;
                         float z1 = 
(nSpaceWidth/10.0+((fSpaceNormal-nSpaceWidth/10.0)*fExpansionWeight))/(nSpaceWidth/10.0);
                         // TODO shrink line portions only if needed

Reply via email to