From e7afef0a702f537dda9af8297ae705f7c30d1a77 Mon Sep 17 00:00:00 2001 From: Evgeny Igumnov Date: Mon, 15 Jul 2024 11:37:40 +0500 Subject: [PATCH] Bugfix: unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed isize::MAX https://github.com/OSSystems/compress-tools-rs/issues/128 --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 16a4599..e15f126 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -617,7 +617,9 @@ where ffi::ARCHIVE_EOF => return Ok(written), value => archive_result(value, archive_reader)?, } - + if size == 0 { + return Ok(written); + } let content = slice::from_raw_parts(buffer as *const u8, size); target.write_all(content)?; written += size;