Blob Blame History Raw
From 17c7e35232d04b5b32c29b995459e83a4b3a2319 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 3 Jun 2015 08:11:06 +0200
Subject: [PATCH 007/398] -fsanitize=float-divide-by-zero

...happens at least during CppunitTest_sd_tiledrendering that
aCurrTextSize.Height() is zero:

 SdrTextObj::ImpAutoFitText(SdrOutliner&, Size const&, bool) svx/source/svdraw/svdotext.cxx:1312:49
 SdrTextObj::ImpAutoFitText(SdrOutliner&) const svx/source/svdraw/svdotext.cxx:1290:5
 SdrTextObj::BegTextEdit(SdrOutliner&) svx/source/svdraw/svdotxed.cxx:103:9
 SdrObjEditView::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool) svx/source/svdraw/svdedxv.cxx:635:12
 sd::View::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool) sd/source/ui/view/sdview.cxx:704:20
 sd::Outliner::EnterEditMode(bool) sd/source/ui/view/Outliner.cxx:1299:9
 sd::Outliner::PrepareSearchAndReplace() sd/source/ui/view/Outliner.cxx:1181:9
 sd::Outliner::ProvideNextTextObject() sd/source/ui/view/Outliner.cxx:973:29
 sd::Outliner::SearchAndReplaceOnce() sd/source/ui/view/Outliner.cxx:674:17
 sd::Outliner::StartSearchAndReplace(SvxSearchItem const*) sd/source/ui/view/Outliner.cxx:496:28
 sd::FuSearch::SearchAndReplace(SvxSearchItem const*) sd/source/ui/func/fusearch.cxx:132:33
 sd::DrawDocShell::Execute(SfxRequest&) sd/source/ui/docshell/docshel3.cxx:222:21
 SfxStubDrawDocShellExecute(SfxShell*, SfxRequest&) workdir/SdiTarget/sd/sdi/sdslots.hxx:17034:1
 SfxShell::CallExec(void (*)(SfxShell*, SfxRequest&), SfxRequest&) include/sfx2/shell.hxx:210:35
 SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) sfx2/source/control/dispatch.cxx:257:13
 SfxDispatcher::_Execute(SfxShell&, SfxSlot const&, SfxRequest&, SfxCallMode) sfx2/source/control/dispatch.cxx:847:9
 SfxDispatcher::Execute(unsigned short, SfxCallMode, SfxItemSet*, SfxItemSet*, unsigned short) sfx2/source/control/dispatch.cxx:916:9
 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:823:37
 SfxOfficeDispatch::dispatch(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) sfx2/source/control/unoctitm.cxx:359:9
 non-virtual thunk to SfxOfficeDispatch::dispatch(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) sfx2/source/control/unoctitm.cxx:343:34
 comphelper::dispatchCommand(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) comphelper/source/misc/dispatchcommand.cxx:57:5
 lcl_search(rtl::OUString const&) sd/qa/unit/tiledrendering/tiledrendering.cxx:338:5
 SdTiledRenderingTest::testSearch() sd/qa/unit/tiledrendering/tiledrendering.cxx:361:5
 ...

Change-Id: I38ab71c5f4024b2d7270a4f6c2aeb4ef502d08f5
(cherry picked from commit bf93b3d1a4b624c3b58e6429899c47fa7cad6ede)
---
 svx/source/svdraw/svdotext.cxx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 47696fd28204..104f48bee47d 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1307,9 +1307,16 @@ void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize,
         const Size aCurrTextSize = rOutliner.CalcTextSizeNTP();
         double fFactor(1.0);
         if( bIsVerticalWriting )
-            fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
-        else
+        {
+            if (aCurrTextSize.Width() != 0)
+            {
+                fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
+            }
+        }
+        else if (aCurrTextSize.Height() != 0)
+        {
             fFactor = double(rTextSize.Height())/aCurrTextSize.Height();
+        }
         // fFactor scales in both x and y directions
         // - this is fine for bulleted words
         // - but it scales too much for a long paragraph
-- 
2.12.0