diff --git a/lofty/src/mp4/properties.rs b/lofty/src/mp4/properties.rs index 4025b24e3..125f76f0e 100644 --- a/lofty/src/mp4/properties.rs +++ b/lofty/src/mp4/properties.rs @@ -4,6 +4,7 @@ use crate::config::ParsingMode; use crate::error::{LoftyError, Result}; use crate::macros::{decode_err, err, try_vec}; use crate::properties::FileProperties; +use crate::util::alloc::VecFallibleCapacity; use crate::util::math::RoundedDivision; use std::io::{Cursor, Read, Seek, SeekFrom}; @@ -340,7 +341,7 @@ where let _version_and_flags = reader.read_uint::(4)?; let entry_count = reader.read_u32::()?; - let mut entries = Vec::with_capacity(entry_count as usize); + let mut entries = Vec::try_with_capacity_stable(entry_count as usize)?; for _ in 0..entry_count { let sample_count = reader.read_u32::()?; diff --git a/lofty/tests/fuzz/assets/mp4file_read_from/ui_steam_smoother_friend_join_IDX_53_RAND_83672409887817275057956.m4a b/lofty/tests/fuzz/assets/mp4file_read_from/ui_steam_smoother_friend_join_IDX_53_RAND_83672409887817275057956.m4a new file mode 100755 index 000000000..9313ca6f4 Binary files /dev/null and b/lofty/tests/fuzz/assets/mp4file_read_from/ui_steam_smoother_friend_join_IDX_53_RAND_83672409887817275057956.m4a differ diff --git a/lofty/tests/fuzz/mp4file_read_from.rs b/lofty/tests/fuzz/mp4file_read_from.rs index 2717c1567..f49d71b03 100644 --- a/lofty/tests/fuzz/mp4file_read_from.rs +++ b/lofty/tests/fuzz/mp4file_read_from.rs @@ -47,3 +47,11 @@ fn panic5() { ); let _ = Mp4File::read_from(&mut reader, ParseOptions::new()); } + +#[test] +fn panic6() { + let mut reader = crate::get_reader( + "mp4file_read_from/ui_steam_smoother_friend_join_IDX_53_RAND_83672409887817275057956.m4a", + ); + let _ = Mp4File::read_from(&mut reader, ParseOptions::new()); +}