[Kdenlive-devel] [PATCH 04/16] audioCorrelationInfo.cpp: check for division by zero

Mikko Rapeli mikko.rapeli at iki.fi
Fri Aug 10 12:17:05 UTC 2012


Fixes Coverity CID 709286: Division or modulo by zero (DIVIDE_BY_ZERO)
Assigning: "maxVal" = "this->max()".
On this path, function call "this->max()" has return value of 0
78    int64_t maxVal = max();
...
Division by expression "maxVal" which may be zero has undefined behavior
86        val = m_correlationVector[x]/double(maxVal)*img.height();
---
 src/lib/audio/audioCorrelationInfo.cpp |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lib/audio/audioCorrelationInfo.cpp b/src/lib/audio/audioCorrelationInfo.cpp
index ea9e90c..db438bd 100644
--- a/src/lib/audio/audioCorrelationInfo.cpp
+++ b/src/lib/audio/audioCorrelationInfo.cpp
@@ -80,6 +80,9 @@ QImage AudioCorrelationInfo::toImage(int height) const
     QImage img(width, height, QImage::Format_ARGB32);
     img.fill(qRgb(255,255,255));
 
+    if (maxVal == 0)
+	return img;
+
     int val;
 
     for (int x = 0; x < width; x++) {
-- 
1.7.10.4





More information about the Kdenlive mailing list