Fix path with infinite length causing panic (#5457)

This commit is contained in:
Max 2024-11-26 12:39:00 +00:00 committed by GitHub
parent fd5e642fb4
commit 39e41ba3c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 0 deletions

View File

@ -114,6 +114,10 @@ pub fn layout_path(
path.close_path();
}
if !size.is_finite() {
bail!(elem.span(), "cannot create path with infinite length");
}
// Prepare fill and stroke.
let fill = elem.fill(styles);
let fill_rule = elem.fill_rule(styles);

View File

@ -90,3 +90,7 @@
--- line-bad-point-component-type ---
// Error: 14-26 expected relative length, found angle
#line(start: (3deg, 10pt), length: 5cm)
--- line-infinite-length ---
// Error: 2-54 cannot create line with infinite length
#line(start: (0pt, 0pt), end: (float.inf * 1pt, 0pt))

View File

@ -71,6 +71,10 @@
// Error: 7-31 point array must contain exactly two entries
#path(((0%, 0%), (0%, 0%, 0%)))
--- path-infinite-length ---
// Error: 2-42 cannot create path with infinite length
#path((0pt, 0pt), (float.inf * 1pt, 0pt))
--- issue-path-in-sized-container ---
// Paths used to implement `LayoutMultiple` rather than `LayoutSingle` without
// fulfilling the necessary contract of respecting region expansion.

View File

@ -51,3 +51,7 @@
--- polygon-bad-point-array ---
// Error: 10-17 point array must contain exactly two entries
#polygon((50pt,))
--- polygon-infinite-size ---
// Error: 2-57 cannot create polygon with infinite size
#polygon((0pt, 0pt), (0pt, 1pt), (float.inf * 1pt, 0pt))