LibWeb: Prevent overrunning loop bounds in cubic bezier calculation

(cherry picked from commit 7f902fa2dc787bd1212d977babf7ea9eedd328f0)
This commit is contained in:
Matthew Olsson 2024-06-07 15:40:29 -07:00 committed by Nico Weber
parent 3434572089
commit ae4c5512af

View file

@ -95,9 +95,9 @@ double CubicBezierTimingFunction::operator()(double input_progress, bool) const
if (nearby_index == m_cached_x_samples.size() || nearby_index + 1 == m_cached_x_samples.size()) {
// Produce more samples until we have enough.
auto last_t = m_cached_x_samples.is_empty() ? 0 : m_cached_x_samples.last().t;
auto last_x = m_cached_x_samples.is_empty() ? 0 : m_cached_x_samples.last().x;
while (last_x <= x) {
auto last_t = m_cached_x_samples.last().t;
auto last_x = m_cached_x_samples.last().x;
while (last_x <= x && last_t < 1.0) {
last_t += 1. / 60.;
auto solution = solve(last_t);
m_cached_x_samples.append(solution);