From 4b4e26cca3b6648f632a4f947de34d4f2cf309c3 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Mon, 18 Sep 2023 21:51:39 -0700 Subject: [PATCH] Clarify that in_bounds_index has unspecified behavior for invalid indices --- src/flat.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/flat.rs b/src/flat.rs index 24a14d1a21..d21a4f5eb0 100644 --- a/src/flat.rs +++ b/src/flat.rs @@ -426,6 +426,9 @@ impl SampleLayout { /// Assumes that the image is backed by some sufficiently large buffer. Then computation can /// not overflow as we could represent the maximum coordinate. Since overflow is defined either /// way, this method can not be unsafe. + /// + /// Behavior is *unspecified* if the index is out of bounds or this sample layout would require + /// a buffer larger than `isize::MAX` bytes. pub fn in_bounds_index(&self, c: u8, x: u32, y: u32) -> usize { let (c_stride, x_stride, y_stride) = self.strides_cwh(); (y as usize * y_stride) + (x as usize * x_stride) + (c as usize * c_stride)