Skip to content

Commit

Permalink
CID 34798: Division or modulo by float zero (DIVIDE_BY_ZERO)
Browse files Browse the repository at this point in the history
12. divide_by_zero: In expression dist /= count, division by expression
count which may be zero has undefined behavior.
  • Loading branch information
hallarempt committed Sep 26, 2019
1 parent 14ee763 commit f0c028d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/ui/input/kis_zoom_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,12 @@ void KisZoomAction::inputEvent( QEvent* event )
Q_FOREACH (const QTouchEvent::TouchPoint &point, tevent->touchPoints()) {
if (point.state() != Qt::TouchPointReleased) {
count++;

dist += (point.pos() - center).manhattanLength();
}
}
if (count == 0) {
count = 1;
}

dist /= count;
float delta = qFuzzyCompare(1.0f, 1.0f + d->lastDistance) ? 1.f : dist / d->lastDistance;
Expand Down

0 comments on commit f0c028d

Please sign in to comment.