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

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


Fixes Coverity CID 709288: Division or modulo by zero (DIVIDE_BY_ZERO)
Division by expression "STEPS" which may be zero has undefined behavior
139    avg=avg/STEPS;
...
150    return delta / STEPS;
---
 thumbnailer/westleypreview.cpp |    1 +
 1 file changed, 1 insertion(+)

diff --git a/thumbnailer/westleypreview.cpp b/thumbnailer/westleypreview.cpp
index 8512b60..9113278 100644
--- a/thumbnailer/westleypreview.cpp
+++ b/thumbnailer/westleypreview.cpp
@@ -123,6 +123,7 @@ uint MltPreview::imageVariance(QImage image)
     uint delta = 0;
     uint avg = 0;
     uint bytes = image.numBytes();
+    if (bytes == 0) return 0;
     uint STEPS = bytes / 2;
     QVarLengthArray<uchar> pivot(STEPS);
     kDebug(DBG_AREA) << "Using " << STEPS << " steps\n";
-- 
1.7.10.4





More information about the Kdenlive mailing list