From f658532d2ca1f96b177c2578bcd4c8a00dbe81ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 10 Jun 2014 13:44:54 +0100 Subject: [PATCH] coverity#1222230 Division or modulo by zero Change-Id: I98ccd214be79f3d95c023fd5134d09c1cff3ee32 --- vcl/source/bitmap/bitmapscalesuper.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index c48674006b1e..bc4461344a70 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -378,9 +378,14 @@ void scalePallete8bit2(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 ); } }