diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 13:50:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-06-10 16:08:01 +0100 |
commit | 10eceebd2271990d17e5aa2f9a6a22162ef24a17 (patch) | |
tree | 59ec598ec4c38244bab0b012c519df5debba2e04 /vcl/source/bitmap | |
parent | 2fbacba2546bcbc025528e00ef4f1b2bb5950208 (diff) |
coverity#1222226 Division or modulo by zero
Change-Id: I45cbb8dbf2b9e7be6e8dda8603c2ef5f88507d04
Diffstat (limited to 'vcl/source/bitmap')
-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 a65878ac8d26..0ed69628ff07 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -648,9 +648,13 @@ void scale24bitBGR2(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 ); } } |