Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
fix oob if in .get (#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 7, 2023
1 parent 92050ec commit 2ecd3e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,18 @@ pub trait Array: Send + Sync + dyn_clone::DynClone + 'static {
/// Panics iff `i >= self.len()`.
#[inline]
fn is_null(&self, i: usize) -> bool {
assert!(i < self.len());
unsafe { self.is_null_unchecked(i) }
}

/// Returns whether slot `i` is null.
/// # Safety
/// The caller must ensure `i < self.len()`
#[inline]
unsafe fn is_null_unchecked(&self, i: usize) -> bool {
self.validity()
.as_ref()
.map(|x| !x.get_bit(i))
.map(|x| !x.get_bit_unchecked(i))
.unwrap_or(false)
}

Expand Down
2 changes: 1 addition & 1 deletion src/io/ipc/read/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn read_file_metadata<R: Read + Seek>(reader: &mut R) -> Result<FileMetadata
let start = reader.stream_position()?;
reader.read_exact(&mut magic_buffer)?;
if magic_buffer != ARROW_MAGIC_V2 {
if &magic_buffer[..4] == ARROW_MAGIC_V1 {
if magic_buffer[..4] == ARROW_MAGIC_V1 {
return Err(Error::NotYetImplemented("feather v1 not supported".into()));
}
return Err(Error::from(OutOfSpecKind::InvalidHeader));
Expand Down

0 comments on commit 2ecd3e8

Please sign in to comment.