pathops: a huge stroke width with round joins no longer panics Outline Stroke

normalize_bez ran the sweep without the catch_unwind guard that Sweep::new has,
so an outline_stroke width of 1e200 or more with a round join panicked inside
linesweeper (Left == Ish). The panic is now a Degenerate error and the art is
left unchanged. Adds hostile-number tests for the pathops edit, stroke and
offset functions.
This commit is contained in:
jayzed80
2026-10-30 16:55:51 +07:00
committed by bflatastic
parent a8ec515e1c
commit c9504597ea
3 changed files with 54 additions and 2 deletions
+4 -2
View File
@@ -656,8 +656,10 @@ pub(crate) fn normalize_bez(bp: &BezPath, rule: FillRule) -> Result<Contours, Pa
if !crate::budget::sweep_fits([&bp]) {
return Err(PathOpsError::TooComplex);
}
let top = Topology::<i32>::from_path(&bp, eps).map_err(|_| PathOpsError::OpenPath)?;
Ok(top.contours(|w| inside(rule, *w)))
// As in `Sweep::new`, a panic in the sweep on near-degenerate input becomes an error.
let swept =
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| Topology::<i32>::from_path(&bp, eps).map(|top| top.contours(|w| inside(rule, *w)))));
swept.map_err(|_| PathOpsError::Degenerate)?.map_err(|_| PathOpsError::OpenPath)
}
/// Boolean operation between two filled paths. Returns an empty path on invalid (non-finite) input.