2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

QtLottie: Fix UB in last keyframe easing point.

Example: https://lottiefiles.com/427-happy-birthday

The present box top was rendered below the body or not depending on
the uninitialized bytes from QBezier.
This commit is contained in:
John Preston
2019-04-29 19:08:00 +04:00
parent f073963582
commit 2fae2278f7
2 changed files with 9 additions and 4 deletions

View File

@@ -112,9 +112,14 @@ public:
int adjustedFrame = qBound(m_startFrame, frame, m_endFrame);
if (const EasingSegment<QPointF> *easing = getEasingSegment(adjustedFrame)) {
qreal progress = ((adjustedFrame - m_startFrame) * 1.0) / (m_endFrame - m_startFrame);
qreal easedValue = easing->easing.valueForProgress(progress);
m_value = m_bezierPath.pointAtPercent(easedValue);
if (easing->complete) {
qreal progress = ((adjustedFrame - m_startFrame) * 1.0) / (m_endFrame - m_startFrame);
qreal easedValue = easing->easing.valueForProgress(progress);
m_value = m_bezierPath.pointAtPercent(easedValue);
} else {
// In case of incomplete easing we should just take the final point.
m_value = m_bezierPath.pointAtPercent(1.);
}
}
return true;