geoHeil commented on code in PR #12077:
URL: https://github.com/apache/arrow-rs/pull/12077#discussion_r4478052619


##########
arrow-ipc/src/compression.rs:
##########
@@ -308,21 +308,7 @@ fn compress_lz4(_input: &[u8], _output: &mut Vec<u8>) -> 
Result<(), ArrowError>
 
 #[cfg(feature = "lz4")]
 fn decompress_lz4(input: &[u8], decompressed_size: usize) -> Result<Vec<u8>, 
ArrowError> {
-    use std::io::Read;
-    let mut output = Vec::with_capacity(decompressed_size);
-    let mut decoder = lz4_flex::frame::FrameDecoder::new(input);
-    decoder
-        .by_ref()
-        .take(decompressed_size as u64)
-        .read_to_end(&mut output)?;
-
-    // Probe without growing `output` to reject data exceeding the advertised 
size.
-    if decoder.read(&mut [0])? != 0 {
-        return Err(ArrowError::IpcError(format!(
-            "LZ4 decompressed buffer exceeds advertised size of 
{decompressed_size}"
-        )));
-    }
-    Ok(output)
+    read_to_end_bounded(lz4_flex::frame::FrameDecoder::new(input), 
decompressed_size)

Review Comment:
   streamlined



-- 
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]

Reply via email to