scovich commented on code in PR #9817:
URL: https://github.com/apache/arrow-rs/pull/9817#discussion_r3149057394


##########
arrow-row/src/lib.rs:
##########
@@ -1255,14 +1255,20 @@ impl Rows {
 
     /// Returns the row at index `row`
     pub fn row(&self, row: usize) -> Row<'_> {
-        assert!(row + 1 < self.offsets.len());
+        self.checked_row_end(row);
         unsafe { self.row_unchecked(row) }
     }
 
+    fn checked_row_end(&self, row: usize) -> usize {
+        row.checked_add(1)
+            .filter(|end| *end < self.offsets.len())
+            .expect("row index out of bounds")

Review Comment:
   > I do think trying to access memory at offset `uisze::MAX` will then most 
likely then cause a SIGSEGV, but it seemed better to check the corner case 
anyway
   
   Yeah, IIRC 
[vec](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.with_capacity) 
specifically documents a panic if you try to grow it beyond `isize::MAX` 
entries. Not sure if the same applies to slices ion general or if that's a 
vec-specific thing?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to