diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 13:42:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 16:08:00 +0100 |
commit | da62285f6b0aee36ce99223b5e568a3994e74255 (patch) | |
tree | 63f475214e746bda8ccea70b6142b50dcc7b1267 /vcl | |
parent | aaaf24322e95b74af0e46e01e9a35a1871fa1be2 (diff) |
coverity#1222232 Division or modulo by zero
Change-Id: I4a3921df8e6510a37702ae8bd4856ba43c98213a
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/bitmap/bitmapscalesuper.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 0b4be8cec6fc..b95f4ce96b0e 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -502,9 +502,14 @@ void scalePalleteGeneral2(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 ); } } |