diff --git a/src/lib.rs b/src/lib.rs index b7c8826..48fa8a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) { + 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();