scovich commented on code in PR #7752:
URL: https://github.com/apache/arrow-rs/pull/7752#discussion_r2164896333
##########
parquet-variant/src/decoder.rs:
##########
@@ -262,21 +265,19 @@ pub(crate) fn decode_timestampntz_micros(data: &[u8]) ->
Result<NaiveDateTime, A
/// Decodes a Binary from the value section of a variant.
pub(crate) fn decode_binary(data: &[u8]) -> Result<&[u8], ArrowError> {
let len = u32::from_le_bytes(array_from_slice(data, 0)?) as usize;
- let value = slice_from_slice(data, 4..4 + len)?;
- Ok(value)
+ slice_from_slice_at_offset(data, 4, 0..len)
Review Comment:
The conversion of `len` from `u32` to `usize` isn't the problem (unless we
worry about supporting 16-bit architectures). It's the `4 + len` (or more
generally `offset + len`) that may overflow on a 32-bit architecture, if e.g.
`len` contains `u32::MAX`. By moving the offset arithmetic into the helper
method, we make it easy to do the right thing; otherwise it's easy to do the
wrong thing (`+` instead of `checked_add`).
--
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]