diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 13:46:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 16:08:01 +0100 |
commit | 434546a28db713f05961b1e5dc63d7f7fdef34e1 (patch) | |
tree | 6552815a85dc5d6c95942878b3ef945826841ab3 | |
parent | f658532d2ca1f96b177c2578bcd4c8a00dbe81ef (diff) |
coverity#1222229 Division or modulo by zero
Change-Id: I97fd23d19a96665b91154ed260c677f0f76fee47
-rw-r--r-- | vcl/source/bitmap/bitmapscalesuper.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index bc4461344a70..a7a263f0db75 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -372,9 +372,16 @@ void scalePallete8bit2(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; } |