From cdd7f79d333a441bed9fc0bf117760085f48bc32 Mon Sep 17 00:00:00 2001 From: MadsWedendahlKruse Date: Thu, 30 Oct 2025 17:23:45 +0100 Subject: [PATCH] fix: guard against out-of-bounds access in Path implementation --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fbf42c6..6272b4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,8 +113,8 @@ impl Path { for polygon_index in &self.path_through_polygons[step..] { let layer = &mesh.layers[polygon_index.layer() as usize]; let polygon = &layer.polygons[polygon_index.polygon() as usize]; - if self.path.len() < next_i { - // TODO: shouldn't happen + // Guard: stop once we've consumed all waypoints. + if next_i >= self.path.len() { break; } if polygon.contains(layer, self.path[next_i]) {