mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 05:37:23 -06:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user