Skip to content

Commit

Permalink
ArrayBufferReader assumes flatbuffers are validated (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 authored Aug 13, 2024
1 parent f9a6f20 commit 7184c2f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vortex-serde/src/message_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,13 @@ impl ArrayBufferReader {
Ok(Some(bytes.get_u32_le() as usize))
}
ReadState::ReadingFb => {
let batch = root::<fb::Message>(&bytes)?
.header_as_batch()
.ok_or_else(|| vortex_err!("Message was not a batch"))?;
// SAFETY: Assumes that any flatbuffer bytes passed have been validated.
// This is currently the case in stream and file implementations.
let batch = unsafe {
root_unchecked::<fb::Message>(&bytes)
.header_as_batch()
.ok_or_else(|| vortex_err!("Message was not a batch"))?
};
let buffer_size = batch.buffer_size() as usize;
self.fb_msg = Some(Buffer::from(bytes));
self.state = ReadState::ReadingBuffers;
Expand All @@ -269,7 +273,6 @@ impl ArrayBufferReader {
// Split out into individual buffers
// Initialize the column's buffers for a vectored read.
// To start with, we include the padding and then truncate the buffers after.
// let all_buffers_size = self.fb_msg.expect()
let batch_msg = unsafe {
root_unchecked::<fb::Message>(
self.fb_msg
Expand Down

0 comments on commit 7184c2f

Please sign in to comment.