summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/visualize/polygon.rs
diff options
context:
space:
mode:
authorbluebear94 <uruwi@protonmail.com>2023-10-05 04:26:36 -0400
committerGitHub <noreply@github.com>2023-10-05 10:26:36 +0200
commit6bb776029e5d3261bd79605f91eb1e7fd14d06ea (patch)
tree17c6f352d848731309580c3dbe0c9f08304d7b38 /crates/typst-library/src/visualize/polygon.rs
parentea0f22a8ca2eec4bde44fc4afc6032c2728aed27 (diff)
Fix crashes with infinite lengths (part 2) (#2298)
Diffstat (limited to 'crates/typst-library/src/visualize/polygon.rs')
-rw-r--r--crates/typst-library/src/visualize/polygon.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/crates/typst-library/src/visualize/polygon.rs b/crates/typst-library/src/visualize/polygon.rs
index 1d19a94d..b1ed9eaa 100644
--- a/crates/typst-library/src/visualize/polygon.rs
+++ b/crates/typst-library/src/visualize/polygon.rs
@@ -130,6 +130,9 @@ impl Layout for PolygonElem {
.collect();
let size = points.iter().fold(Point::zero(), |max, c| c.max(max)).to_size();
+ if !size.is_finite() {
+ bail!(error!(self.span(), "cannot create polygon with infinite size"));
+ }
let mut frame = Frame::hard(size);
// Only create a path if there are more than zero points.