alamb commented on code in PR #9922:
URL: https://github.com/apache/arrow-rs/pull/9922#discussion_r3190725246
##########
arrow-row/src/lib.rs:
##########
@@ -1132,14 +1132,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")
+ }
+
/// Returns the row at `index` without bounds checking
Review Comment:
As the description points out the reason
https://github.com/apache/arrow-rs/pull/9817 has more changes than this PR is:
> Note: Rows::row_len and Rows::lengths are not present on the
57_maintenance line, so this backport applies the checked row index validation
to Rows::row and includes the row_unchecked safety documentation update from
the original PR.
This was introduced in
- https://github.com/apache/arrow-rs/pull/9079 /
https://github.com/apache/arrow-rs/commit/13d497af2be5d91c1c57775b8a57487ca05babe3
which was first released in 58.2.0
--
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]