summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-04 09:56:28 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-04 20:44:53 +0000
commitf075a3ad08f7d5b53790076d1965818e57628afa (patch)
treefcd8a9c01bc5f582c51f37716871ba56ca7d259f /svx
parent69b5df30136b778e23eb31c66b81c5524eae903e (diff)
coverity#735623 Division or modulo by float zero
Change-Id: Ibd53687416a4e20af7ac4a1e02c54407892aa470
Diffstat (limited to 'svx')
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index ae31f0080514..7332449b75b2 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -552,12 +552,20 @@ void CalcDistances( const Polygon& rPoly, std::vector< double >& rDistances )
void InsertMissingOutlinePoints( const Polygon& /*rOutlinePoly*/, const std::vector< double >& rDistances, const Rectangle& rTextAreaBoundRect, Polygon& rPoly )
{
- sal_uInt16 i = 0;
+ sal_uInt16 nSize = rPoly.GetSize();
+ if (nSize == 0)
+ return;
+
+ long nTextWidth = rTextAreaBoundRect.GetWidth();
+
+ if (nTextWidth == 0)
+ throw o3tl::divide_by_zero();
+
double fLastDistance = 0.0;
- for ( i = 0; i < rPoly.GetSize(); i++ )
+ for (sal_uInt16 i = 0; i < nSize; ++i)
{
Point& rPoint = rPoly[ i ];
- double fDistance = (double)( rPoint.X() - rTextAreaBoundRect.Left() ) / (double)rTextAreaBoundRect.GetWidth();
+ double fDistance = (double)( rPoint.X() - rTextAreaBoundRect.Left() ) / (double)nTextWidth;
if ( i )
{
if ( fDistance > fLastDistance )