diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 13:48:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 16:08:01 +0100 |
commit | 07dc4bc71bfa6e4f0fb042102c23c43e4268e04e (patch) | |
tree | 394de8402cef9fcecd0c691b807c60f78fa3a9f7 | |
parent | 434546a28db713f05961b1e5dc63d7f7fdef34e1 (diff) |
coverity#1222228 Division or modulo by zero
Change-Id: Icc2bc53a14503f723977dc62252f23327de2dc0d
-rw-r--r-- | vcl/source/bitmap/bitmapscalesuper.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index a7a263f0db75..95858eea5ae0 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -768,9 +768,13 @@ void scale24bitRGB2(BitmapReadAccess* pAcc, BitmapWriteAccess* pWAcc, nTotalWeightY += nWeightY; } - BitmapColor aColRes( ( sal_uInt8 ) (( nSumR / nTotalWeightY ) ), - ( sal_uInt8 ) (( nSumG / nTotalWeightY) ), - ( sal_uInt8 ) (( nSumB / nTotalWeightY) )); + if (nTotalWeightY) + { + nSumR /= nTotalWeightY; + nSumG /= nTotalWeightY; + nSumB /= nTotalWeightY; + } + BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); pWAcc->SetPixel( nYDst, nXDst++, aColRes ); } } |