diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-01 15:55:14 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-01 21:02:10 +0000 |
commit | eed1ea797acfe69af587adbefe60316ba6ba127f (patch) | |
tree | 6ff85540c568b4f2cfb7e3023b1ee2eff6cf637d /svtools/source/brwbox/datwin.cxx | |
parent | 445ac42cc2f2f759a43d97198039b980026ed70e (diff) |
coverity#1250406 Division or modulo by float zero
and
coverity#1250407 Division or modulo by float zero
coverity#1250408 Division or modulo by float zero
Change-Id: I77e4483356f7c0b287a29637cf6b958ee665ffec
Diffstat (limited to 'svtools/source/brwbox/datwin.cxx')
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index 91bff8b52be8..b2fea467c553 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -19,9 +19,8 @@ #include "datwin.hxx" - +#include <o3tl/numeric.hxx> #include <vcl/svapp.hxx> - #include <vcl/help.hxx> #include <vcl/image.hxx> #include <vcl/settings.hxx> @@ -101,8 +100,6 @@ void ButtonFrame::Draw( OutputDevice& rDev ) rDev.SetFillColor( aOldFillColor ); } - - BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom ) : _nId( nItemId ), @@ -114,6 +111,8 @@ BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, double n = (double)_nWidth; n *= (double)rCurrentZoom.GetDenominator(); n /= (double)rCurrentZoom.GetNumerator(); + if (!rCurrentZoom.GetNumerator()) + throw o3tl::divide_by_zero(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } @@ -121,19 +120,17 @@ BrowserColumn::~BrowserColumn() { } - - void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom) { _nWidth = nNewWidthPixel; double n = (double)_nWidth; n *= (double)rCurrentZoom.GetDenominator(); + if (!rCurrentZoom.GetNumerator()) + throw o3tl::divide_by_zero(); n /= (double)rCurrentZoom.GetNumerator(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } - - void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs ) { if ( _nId == 0 ) |