From 434546a28db713f05961b1e5dc63d7f7fdef34e1 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 10 Jun 2014 13:46:25 +0100 Subject: coverity#1222229 Division or modulo by zero Change-Id: I97fd23d19a96665b91154ed260c677f0f76fee47 --- vcl/source/bitmap/bitmapscalesuper.cxx | 13 ++++++++++--- 1 file 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; } -- cgit