From 59e9619ef91322f124b383b80fc21cd09a758017 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 10 Jun 2014 13:51:37 +0100 Subject: coverity#1222225 Division or modulo by zero Change-Id: I9a60114833c22d498dbb6258fcb2ceac22c72751 --- vcl/source/bitmap/bitmapscalesuper.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 0ed69628ff07..13b65e6dc4d9 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -642,9 +642,15 @@ void scale24bitBGR2(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