summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-28 16:23:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-10-29 10:40:06 +0000
commit27277d76bbfedc97942a0de3200d363fca851614 (patch)
tree58ef3122c8a1c567d2b280787218540b137e7892 /filter
parent1ed46f6cb71ddf274490f2f851ca5566fbfb7ae2 (diff)
coverity#1078542 Division or modulo by zero
Change-Id: I3325328c01b23d43c774db4af080df535f47787b
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/epict/epict.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/filter/source/graphicfilter/epict/epict.cxx b/filter/source/graphicfilter/epict/epict.cxx
index 1aad8c1e22db..3fe0455e2e3f 100644
--- a/filter/source/graphicfilter/epict/epict.cxx
+++ b/filter/source/graphicfilter/epict/epict.cxx
@@ -1745,7 +1745,6 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
VirtualDevice aVirDev;
boost::scoped_array<long> pDXAry(new long[ aStr.getLength() ]);
sal_Int32 nNormSize( aVirDev.GetTextArray( aStr,pDXAry.get() ) );
- sal_uInt16 i;
if (aSrcFont.GetAlign()!=ALIGN_BASELINE)
{
@@ -1755,8 +1754,14 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF )
aPt.Y()-=(long)aVirDev.GetFontMetric(aSrcFont).GetDescent();
}
- for ( i = 0; i < aStr.getLength() - 1; i++ )
- pDXAry[ i ] = pDXAry[ i ] * ( (long)pA->GetWidth() ) / nNormSize;
+ sal_Int32 nLength = aStr.getLength() - 1;
+ if (nLength > 0)
+ {
+ if (nNormSize == 0)
+ throw std::runtime_error("divide by zero");
+ for (sal_Int32 i = 0; i < nLength; ++i)
+ pDXAry[ i ] = pDXAry[ i ] * ( (long)pA->GetWidth() ) / nNormSize;
+ }
SetAttrForText();
WriteTextArray( aPt, aStr, pDXAry.get() );