summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-10 13:44:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-06-10 16:08:00 +0100
commitf658532d2ca1f96b177c2578bcd4c8a00dbe81ef (patch)
treed491ddbe1612bcb41f3ac1da2481b9fce6278dff /vcl
parentc7661d5af5b230d567cabd83009da6762a5e91f7 (diff)
coverity#1222230 Division or modulo by zero
Change-Id: I98ccd214be79f3d95c023fd5134d09c1cff3ee32
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/bitmapscalesuper.cxx11
1 files 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 );
}
}