summaryrefslogtreecommitdiff
path: root/vcl/source/bitmap/bitmapscalesuper.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-10 13:38:51 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-06-10 16:07:59 +0100
commitb311aab85f8a26d40d3b87329212288f653dafbc (patch)
treec4cb002129bf1841ef353709b1383f6b92cbdcd1 /vcl/source/bitmap/bitmapscalesuper.cxx
parenta903cac829f0c607b5895cbaae51ab4951ed8567 (diff)
coverity#1222234 Division or modulo by zero
Change-Id: I2832f99c1b4117d1c6d4621f25339e5921d26cb1
Diffstat (limited to 'vcl/source/bitmap/bitmapscalesuper.cxx')
-rw-r--r--vcl/source/bitmap/bitmapscalesuper.cxx12
1 files 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 );
}
}
}