fix other uses of MAX_INITIAL_CAPACITY_BYTES

fix  panic when the output type is zero sized
This commit is contained in:
Geoffroy Couprie 2023-01-15 20:15:00 +01:00 committed by Geoffroy Couprie
parent ee7ad17086
commit a534b39078

View File

@ -392,7 +392,8 @@ where
return Err(Err::Failure(E::from_error_kind(input, ErrorKind::ManyMN)));
}
let max_initial_capacity = MAX_INITIAL_CAPACITY_BYTES / crate::lib::std::mem::size_of::<O>();
let max_initial_capacity =
MAX_INITIAL_CAPACITY_BYTES / crate::lib::std::mem::size_of::<O>().max(1);
let mut res = crate::lib::std::vec::Vec::with_capacity(min.min(max_initial_capacity));
for count in 0..max {
let len = input.input_len();