From 7c55cefc6b7b1da19b2bbe7f43daaba4f816f27d Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 11 Oct 2026 16:57:12 +0200 Subject: fix(engine): add type & bounds checks in shader cursor element fn --- engine/src/rendering/shader/cursor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/src/rendering/shader/cursor.rs b/engine/src/rendering/shader/cursor.rs index 551830d..24d0135 100644 --- a/engine/src/rendering/shader/cursor.rs +++ b/engine/src/rendering/shader/cursor.rs @@ -105,6 +105,13 @@ impl<'a> Cursor<'a> #[must_use] pub fn element(mut self, index: usize) -> Self { + debug_assert_eq!(self.type_layout.kind(), TypeKind::Array); + + debug_assert!( + index < self.type_layout.element_cnt().unwrap_or(0), + "Array element index {index} is out of bounds" + ); + let element_type_layout = self.type_layout.element_type_layout().unwrap(); self.binding_location.byte_offset += index * element_type_layout.stride(); -- cgit v1.2.3-18-g5258