Skip to content

Commit

Permalink
Merge pull request #2009 from fintelia/issue-2005
Browse files Browse the repository at this point in the history
Clarify that `SampleLayout::in_bounds_index` has unspecified behavior for invalid indices
  • Loading branch information
fintelia authored Sep 19, 2023
2 parents 52f5219 + 4b4e26c commit aacfb62
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aacfb62

Please sign in to comment.