From 673dd3f32e4ef04bdad6fb66dae05b3cb1b8f6b1 Mon Sep 17 00:00:00 2001 From: Ink Open Source Date: Mon, 22 Jul 2024 10:16:06 -0700 Subject: [PATCH] Fix a bug in KalmanPredictor from FuzzTest. PiperOrigin-RevId: 654803448 --- ink_stroke_modeler/internal/prediction/kalman_predictor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ink_stroke_modeler/internal/prediction/kalman_predictor.cc b/ink_stroke_modeler/internal/prediction/kalman_predictor.cc index 81b3d8f..6bad195 100644 --- a/ink_stroke_modeler/internal/prediction/kalman_predictor.cc +++ b/ink_stroke_modeler/internal/prediction/kalman_predictor.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -151,7 +152,8 @@ void KalmanPredictor::ConstructCubicConnector( // to the estimated position, based on the start and end velocities. We define // a minimum "reasonable" velocity to avoid division by zero. float distance_traveled = - Distance(last_tip_state.position, estimated_state.position); + std::min(Distance(last_tip_state.position, estimated_state.position), + std::numeric_limits::max()); float max_velocity_at_ends = std::max(last_tip_state.velocity.Magnitude(), estimated_state.velocity.Magnitude()); Duration target_duration{