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 | |
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')
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 6 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 13 |
2 files changed, 8 insertions, 11 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index caf2b417cb8a..51bfecb6114b 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -19,6 +19,7 @@ #include <svtools/brwbox.hxx> #include <svtools/brwhead.hxx> +#include <o3tl/numeric.hxx> #include "datwin.hxx" #include <tools/debug.hxx> #include <tools/stream.hxx> @@ -2418,7 +2419,6 @@ long BrowseBox::GetTitleHeight() const return nTitleLines ? nTitleLines * nHeight + 4 : 0; } - long BrowseBox::CalcReverseZoom(long nVal) { if (IsZoom()) @@ -2426,6 +2426,8 @@ long BrowseBox::CalcReverseZoom(long nVal) const Fraction& rZoom = GetZoom(); double n = (double)nVal; n *= (double)rZoom.GetDenominator(); + if (!rZoom.GetNumerator()) + throw o3tl::divide_by_zero(); n /= (double)rZoom.GetNumerator(); nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5); } @@ -2445,8 +2447,6 @@ void BrowseBox::CursorMoved() ); } - - void BrowseBox::LoseFocus() { OSL_TRACE( "BrowseBox: %p->LoseFocus", this ); 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 ) |