[Kdenlive-devel] [PATCH 08/16] kthumb.cpp: check for division by zero
Mikko Rapeli
mikko.rapeli at iki.fi
Fri Aug 10 12:17:09 UTC 2012
CID 709285: Division or modulo by zero (DIVIDE_BY_ZERO)
Division by expression "STEPS" which may be zero has undefined behavior
250 avg=avg/STEPS;
---
src/kthumb.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/kthumb.cpp b/src/kthumb.cpp
index c5e1691..428d437 100644
--- a/src/kthumb.cpp
+++ b/src/kthumb.cpp
@@ -247,7 +247,8 @@ uint KThumb::imageVariance(QImage image )
avg+=pivot[i];
#endif
}
- avg=avg/STEPS;
+ if (STEPS)
+ avg=avg/STEPS;
// Second Step: calculate delta (average?)
for (uint i=0; i<STEPS; i++)
{
@@ -258,7 +259,10 @@ uint KThumb::imageVariance(QImage image )
#endif
delta+=curdelta;
}
- return delta/STEPS;
+ if (STEPS)
+ return delta/STEPS;
+ else
+ return 0;
}
/*
--
1.7.10.4
More information about the Kdenlive
mailing list