Skip to content

Commit

Permalink
fix(storage): fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Feb 2, 2024
1 parent dde824e commit 2dca292
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/storage/src/hummock/sstable/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ impl Block {
.map_err(HummockError::decode_error)?;
let mut decoded = BytesMut::with_capacity(uncompressed_capacity);
unsafe { decoded.set_len(uncompressed_capacity) }
decoder
let actual_size = decoder
.read(&mut decoded)
.map_err(HummockError::decode_error)?;
unsafe {
decoded.set_len(actual_size);
}
debug_assert_eq!(decoded.capacity(), uncompressed_capacity);
decoded.freeze()
}
Expand All @@ -227,9 +230,12 @@ impl Block {
.map_err(HummockError::decode_error)?;
let mut decoded = BytesMut::with_capacity(uncompressed_capacity);
unsafe { decoded.set_len(uncompressed_capacity) }
decoder
let actual_size = decoder
.read(&mut decoded)
.map_err(HummockError::decode_error)?;
unsafe {
decoded.set_len(actual_size);
}
debug_assert_eq!(decoded.capacity(), uncompressed_capacity);
decoded.freeze()
}
Expand Down

0 comments on commit 2dca292

Please sign in to comment.