etseidl commented on code in PR #9797:
URL: https://github.com/apache/arrow-rs/pull/9797#discussion_r3132070010
##########
parquet/src/encodings/decoding.rs:
##########
@@ -1134,7 +1134,22 @@ impl<T: DataType> Decoder<T> for
DeltaByteArrayDecoder<T> {
let suffix = v[0].data();
// Extract current prefix length, can be 0
- let prefix_len = self.prefix_lengths[self.current_idx] as
usize;
+ let prefix_len_i32 = self.prefix_lengths[self.current_idx];
+ if prefix_len_i32 < 0 {
+ return Err(general_err!(
+ "Invalid DELTA_BYTE_ARRAY prefix length {}",
+ prefix_len_i32
+ ));
+ }
+ let prefix_len = prefix_len_i32 as usize;
Review Comment:
```suggestion
let prefix_len =
usize::try_from(self.prefix_lengths[self.current_idx])?;
```
A little less verbose. 😄
I notice the added test doesn't cover this possibility.
--
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]