From b311aab85f8a26d40d3b87329212288f653dafbc Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 10 Jun 2014 13:38:51 +0100 Subject: coverity#1222234 Division or modulo by zero Change-Id: I2832f99c1b4117d1c6d4621f25339e5921d26cb1 --- vcl/source/bitmap/bitmapscalesuper.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 4d81c99c3acf..4620c552286b 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -867,11 +867,15 @@ void scaleNonPalleteGeneral2(BitmapReadAccess* pAcc, BitmapWriteAccess* pWAcc, nTotalWeightY += nWeightY; } - BitmapColor aColRes( ( sal_uInt8 ) (( nSumR / nTotalWeightY) ), - ( sal_uInt8 ) (( nSumG / nTotalWeightY) ), - ( sal_uInt8 ) (( nSumB / nTotalWeightY) )); - pWAcc->SetPixel( nYDst, nXDst++, aColRes ); + if (nTotalWeightY) + { + nSumR /= nTotalWeightY; + nSumG /= nTotalWeightY; + nSumB /= nTotalWeightY; + } + BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumR, (sal_uInt8)nSumB); + pWAcc->SetPixel( nYDst, nXDst++, aColRes ); } } } -- cgit