Skip to content

Commit

Permalink
compress empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Sep 17, 2024
1 parent a3839c7 commit 08c8395
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ impl Compressor {
/// It is up to the caller to ensure the provided buffer is large enough to hold
/// all encoded data.
pub unsafe fn compress_into(&self, plaintext: &[u8], values: &mut Vec<u8>) {
if plaintext.is_empty() {
// SAFETY: no data written
values.set_len(0);
return;
}
let mut in_ptr = plaintext.as_ptr();
let mut out_ptr = values.as_mut_ptr();

Expand Down

0 comments on commit 08c8395

Please sign in to comment.