From d53d2d61b6c097c6637d78beb7d3f72c260acaf2 Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Sat, 13 May 2023 14:04:17 -0700 Subject: [PATCH] Bug fix in Arbitrary impl --- src/write.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/write.rs b/src/write.rs index 26667882..b1e62b3a 100644 --- a/src/write.rs +++ b/src/write.rs @@ -142,14 +142,14 @@ pub struct FileOptions { impl arbitrary::Arbitrary for FileOptions { fn arbitrary(u: &mut Unstructured) -> arbitrary::Result { let mut options = FileOptions { - compression_method: CompressionMethod::arbitrary(&mut u), - compression_level: Option::::arbitrary(&mut u), - last_modified_time: DateTime::arbitrary(&mut u), - permissions: Option::::arbitrary(&mut u), - large_file: bool::arbitrary(&mut u), - encrypt_with: Option::::arbitrary(&mut u), - extra_data: Vec::with_capacity(u16::MAX as usize), - central_extra_data: Vec::with_capacity(u16::MAX as usize), + compression_method: CompressionMethod::arbitrary(&mut u)?, + compression_level: Option::::arbitrary(&mut u)?, + last_modified_time: DateTime::arbitrary(&mut u)?, + permissions: Option::::arbitrary(&mut u)?, + large_file: bool::arbitrary(&mut u)?, + encrypt_with: Option::::arbitrary(&mut u)?, + extra_data: Vec::with_capacity(u16::MAX as usize)?, + central_extra_data: Vec::with_capacity(u16::MAX as usize)?, }; #[derive(arbitrary::Arbitrary)] struct ExtraDataField { @@ -157,12 +157,12 @@ impl arbitrary::Arbitrary for FileOptions { data: Vec, central_only: bool, } - let extra_data = Vec::::arbitrary(&mut u); + let extra_data = Vec::::arbitrary(&mut u)?; for field in extra_data { let _ = options.add_extra_data(field.header_id, field.data.as_slice(), field.central_only); } - options + Ok(options) } }