Skip to content

Commit

Permalink
fix error: benchmark/nydus-build
Browse files Browse the repository at this point in the history
  • Loading branch information
fappy1234567 committed Jul 25, 2024
1 parent ecc1f6c commit 9e922fe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions utils/src/compress/lz4_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ pub(super) fn lz4_compress(src: &[u8]) -> Result<Vec<u8>> {
// 0 iff src too large
let compress_bound: i32 = unsafe { LZ4_compressBound(src.len() as i32) };

if src.len() > (i32::max_value() as usize) || compress_bound <= 0 {
// if src.len() > (i32::max_value() as usize) || compress_bound <= 0 {
// return Err(einval!("compression input data is too big"));
// }
if src.len() > (i32::MAX as usize) || compress_bound <= 0 {
return Err(einval!("compression input data is too big"));
}

Expand All @@ -34,7 +37,10 @@ pub(super) fn lz4_compress(src: &[u8]) -> Result<Vec<u8>> {
}

pub(super) fn lz4_decompress(src: &[u8], dst: &mut [u8]) -> Result<usize> {
if dst.len() >= std::i32::MAX as usize {
// if dst.len() >= std::i32::MAX as usize {
// return Err(einval!("the destination buffer is big than i32::MAX"));
// }
if dst.len() >= i32::MAX as usize {
return Err(einval!("the destination buffer is big than i32::MAX"));
}
let size = dst.len() as i32;
Expand Down

0 comments on commit 9e922fe

Please sign in to comment.