[Kdenlive-devel] [PATCH 05/16] audioEnvelope.cpp: check for division by zero
Mikko Rapeli
mikko.rapeli at iki.fi
Fri Aug 10 12:17:06 UTC 2012
Fixes Coverity CID 709287: Division or modulo by zero (DIVIDE_BY_ZERO)
Call to "this->loadEnvelope()" set "this->m_envelopeMax" to 0.
182 loadEnvelope();
...
Division by expression "this->m_envelopeMax" which may be zero has undefined behavior
189 fy = m_envelope[x]/double(m_envelopeMax) * img.height();
---
src/lib/audio/audioEnvelope.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/lib/audio/audioEnvelope.cpp b/src/lib/audio/audioEnvelope.cpp
index 00bda00..d476959 100644
--- a/src/lib/audio/audioEnvelope.cpp
+++ b/src/lib/audio/audioEnvelope.cpp
@@ -184,6 +184,10 @@ QImage AudioEnvelope::drawEnvelope()
QImage img(m_envelopeSize, 400, QImage::Format_ARGB32);
img.fill(qRgb(255,255,255));
+
+ if (m_envelopeMax == 0)
+ return img;
+
double fy;
for (int x = 0; x < img.width(); x++) {
fy = m_envelope[x]/double(m_envelopeMax) * img.height();
--
1.7.10.4
More information about the Kdenlive
mailing list