]> git.sesse.net Git - kdenlive/commitdiff
audioCorrelationInfo.cpp: check for division by zero
authorMikko Rapeli <mikko.rapeli@iki.fi>
Fri, 10 Aug 2012 12:17:05 +0000 (14:17 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 2 Sep 2012 09:40:49 +0000 (11:40 +0200)
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

index ea9e90c2954871ae830237864aeb0ffd663d5a89..db438bdd0a9542935ee909c8978c5b543353aee7 100644 (file)
@@ -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++) {