diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 13:49:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 16:08:01 +0100 |
commit | 2fbacba2546bcbc025528e00ef4f1b2bb5950208 (patch) | |
tree | abcea587711fa263c1610a16e1dc2a5fabd33cad | |
parent | 07dc4bc71bfa6e4f0fb042102c23c43e4268e04e (diff) |
coverity#1222227 Division or modulo by zero
Change-Id: I96b74d164a582cac13c419267879619e6986d71f
-rw-r--r-- | vcl/source/bitmap/bitmapscalesuper.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 95858eea5ae0..a65878ac8d26 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -762,9 +762,15 @@ void scale24bitRGB2(BitmapReadAccess* pAcc, BitmapWriteAccess* pWAcc, else if ( nLineRange == i ) nWeightY = pMapFY[ nBottom ]; - nSumB += nWeightY * ( nSumRowB / nTotalWeightX ); - nSumG += nWeightY * ( nSumRowG / nTotalWeightX ); - nSumR += nWeightY * ( nSumRowR / nTotalWeightX ); + if (nTotalWeightX) + { + nSumRowB /= nTotalWeightX; + nSumRowG /= nTotalWeightX; + nSumRowR /= nTotalWeightX; + } + nSumB += nWeightY * nSumRowB; + nSumG += nWeightY * nSumRowG; + nSumR += nWeightY * nSumRowR; nTotalWeightY += nWeightY; } |