135360
From 17c7e35232d04b5b32c29b995459e83a4b3a2319 Mon Sep 17 00:00:00 2001
135360
From: Stephan Bergmann <sbergman@redhat.com>
135360
Date: Wed, 3 Jun 2015 08:11:06 +0200
135360
Subject: [PATCH 007/398] -fsanitize=float-divide-by-zero
135360
135360
...happens at least during CppunitTest_sd_tiledrendering that
135360
aCurrTextSize.Height() is zero:
135360
135360
 SdrTextObj::ImpAutoFitText(SdrOutliner&, Size const&, bool) svx/source/svdraw/svdotext.cxx:1312:49
135360
 SdrTextObj::ImpAutoFitText(SdrOutliner&) const svx/source/svdraw/svdotext.cxx:1290:5
135360
 SdrTextObj::BegTextEdit(SdrOutliner&) svx/source/svdraw/svdotxed.cxx:103:9
135360
 SdrObjEditView::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool) svx/source/svdraw/svdedxv.cxx:635:12
135360
 sd::View::SdrBeginTextEdit(SdrObject*, SdrPageView*, vcl::Window*, bool, SdrOutliner*, OutlinerView*, bool, bool, bool) sd/source/ui/view/sdview.cxx:704:20
135360
 sd::Outliner::EnterEditMode(bool) sd/source/ui/view/Outliner.cxx:1299:9
135360
 sd::Outliner::PrepareSearchAndReplace() sd/source/ui/view/Outliner.cxx:1181:9
135360
 sd::Outliner::ProvideNextTextObject() sd/source/ui/view/Outliner.cxx:973:29
135360
 sd::Outliner::SearchAndReplaceOnce() sd/source/ui/view/Outliner.cxx:674:17
135360
 sd::Outliner::StartSearchAndReplace(SvxSearchItem const*) sd/source/ui/view/Outliner.cxx:496:28
135360
 sd::FuSearch::SearchAndReplace(SvxSearchItem const*) sd/source/ui/func/fusearch.cxx:132:33
135360
 sd::DrawDocShell::Execute(SfxRequest&) sd/source/ui/docshell/docshel3.cxx:222:21
135360
 SfxStubDrawDocShellExecute(SfxShell*, SfxRequest&) workdir/SdiTarget/sd/sdi/sdslots.hxx:17034:1
135360
 SfxShell::CallExec(void (*)(SfxShell*, SfxRequest&), SfxRequest&) include/sfx2/shell.hxx:210:35
135360
 SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) sfx2/source/control/dispatch.cxx:257:13
135360
 SfxDispatcher::_Execute(SfxShell&, SfxSlot const&, SfxRequest&, SfxCallMode) sfx2/source/control/dispatch.cxx:847:9
135360
 SfxDispatcher::Execute(unsigned short, SfxCallMode, SfxItemSet*, SfxItemSet*, unsigned short) sfx2/source/control/dispatch.cxx:916:9
135360
 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
135360
 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
135360
 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
135360
 comphelper::dispatchCommand(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) comphelper/source/misc/dispatchcommand.cxx:57:5
135360
 lcl_search(rtl::OUString const&) sd/qa/unit/tiledrendering/tiledrendering.cxx:338:5
135360
 SdTiledRenderingTest::testSearch() sd/qa/unit/tiledrendering/tiledrendering.cxx:361:5
135360
 ...
135360
135360
Change-Id: I38ab71c5f4024b2d7270a4f6c2aeb4ef502d08f5
135360
(cherry picked from commit bf93b3d1a4b624c3b58e6429899c47fa7cad6ede)
135360
---
135360
 svx/source/svdraw/svdotext.cxx | 11 +++++++++--
135360
 1 file changed, 9 insertions(+), 2 deletions(-)
135360
135360
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
135360
index 47696fd28204..104f48bee47d 100644
135360
--- a/svx/source/svdraw/svdotext.cxx
135360
+++ b/svx/source/svdraw/svdotext.cxx
135360
@@ -1307,9 +1307,16 @@ void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize,
135360
         const Size aCurrTextSize = rOutliner.CalcTextSizeNTP();
135360
         double fFactor(1.0);
135360
         if( bIsVerticalWriting )
135360
-            fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
135360
-        else
135360
+        {
135360
+            if (aCurrTextSize.Width() != 0)
135360
+            {
135360
+                fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
135360
+            }
135360
+        }
135360
+        else if (aCurrTextSize.Height() != 0)
135360
+        {
135360
             fFactor = double(rTextSize.Height())/aCurrTextSize.Height();
135360
+        }
135360
         // fFactor scales in both x and y directions
135360
         // - this is fine for bulleted words
135360
         // - but it scales too much for a long paragraph
135360
-- 
135360
2.12.0
135360