[Kdenlive-devel] [PATCH 01/16] histogramgenerator.cpp: check for division by zero
Mikko Rapeli
mikko.rapeli at iki.fi
Fri Aug 10 12:17:02 UTC 2012
Fixes Coverity CID 709284: Division or modulo by zero (DIVIDE_BY_ZERO)
Division by expression "byteCount >> 7" which may be zero has undefined behavior
87 const float scaling = (float)partH/(byteCount >> 7);
---
src/colorcorrection/histogramgenerator.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/colorcorrection/histogramgenerator.cpp b/src/colorcorrection/histogramgenerator.cpp
index 456aad6..2681c50 100644
--- a/src/colorcorrection/histogramgenerator.cpp
+++ b/src/colorcorrection/histogramgenerator.cpp
@@ -84,7 +84,10 @@ QImage HistogramGenerator::calculateHistogram(const QSize ¶deSize, const QIm
const int d = 20; // Distance for text
const int partH = (wh-nParts*d)/nParts;
- const float scaling = (float)partH/(byteCount >> 7);
+ float scaling = 0;
+ int div = byteCount >> 7;
+ if ( div > 0 )
+ scaling = (float)partH/(byteCount >> 7);
const int dist = 40;
int wy = 0; // Drawing position
--
1.7.10.4
More information about the Kdenlive
mailing list