mzabaluev commented on code in PR #9397:
URL: https://github.com/apache/arrow-rs/pull/9397#discussion_r2809835871
##########
arrow-avro/src/reader/cursor.rs:
##########
@@ -130,4 +123,27 @@ impl<'a> AvroCursor<'a> {
self.buf = &self.buf[n..];
Ok(ret)
}
+
+ pub(crate) fn skip_int(&mut self) -> Result<(), AvroError> {
+ let offset = vlq::skip_varint(self.buf)
+ .ok_or_else(|| AvroError::ParseError("bad varint".to_string()))?;
+ // Check if the skipped encoded value would fail a conversion to i32;
+ // skip_varint only cares about fitting in a 64-bit value.
+ match offset {
+ ..5 => {}
+ 5 if self.buf[4] < 0x10 => {}
+ _ => return Err(AvroError::ParseError("varint
overflow".to_owned())),
+ }
Review Comment:
I thought of creating another function alongside `skip_varint` for the
32-bit case. But the optimizer should be able to thread the branches of the
unrolled loop in `skip_varint_array` through this. And we don't really care if
the error path of reading an overly long varint, then failing here is not
optimal; `get_int` works the same way.
--
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]