From 51156d5897f31b45f4c7a8fb990f018645a7a466 Mon Sep 17 00:00:00 2001 From: Mikko Rapeli Date: Fri, 10 Aug 2012 14:17:05 +0200 Subject: [PATCH] audioCorrelationInfo.cpp: check for division by zero 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 ea9e90c2..db438bdd 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++) { -- 2.39.2