diff --git a/crates/effects/src/stroke/dash.rs b/crates/effects/src/stroke/dash.rs index 5c47c0743..689c88dae 100644 --- a/crates/effects/src/stroke/dash.rs +++ b/crates/effects/src/stroke/dash.rs @@ -57,6 +57,10 @@ pub fn dash(bp: &BezPath, d: &Dash) -> Option { pat.extend_from_within(..); } let period: f64 = pat.iter().sum(); + // Finite entries can still sum to infinity, which would never leave the phase loop below. + if !period.is_finite() { + return None; + } let plans: Vec = subpaths(bp) .into_iter() .map(|(r, closed)| { diff --git a/crates/effects/src/stroke/tests.rs b/crates/effects/src/stroke/tests.rs index 067064950..1da14b334 100644 --- a/crates/effects/src/stroke/tests.rs +++ b/crates/effects/src/stroke/tests.rs @@ -21,6 +21,11 @@ fn stroke(width: f64, f: impl FnOnce(&mut StrokeLayer)) -> StrokeLayer { st } +#[test] +fn dash_period_overflowing_to_infinity_is_solid() { + assert!(dash(&line(0.0, 60.0), &dashed(&[f64::MAX, f64::MAX], -1.0)).is_none()); +} + fn dashed(pattern: &[f64], offset: f64) -> Dash { Dash { pattern: pattern.to_vec(), offset, align_corners: false } }