mirror of
git://git.proxmox.com/git/pxar.git
synced 2024-12-25 05:33:51 +03:00
don't use size_of_val for possibly empty array elements
While it is generally nicer to use something that already contains the type (to avoid duplicate type names), size_of_val doesn't get optimized out and the array access will happen with all its checks, causing panics... Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
aabb78a451
commit
2c23bd096f
@ -22,7 +22,7 @@ pub mod aio;
|
||||
pub mod sync;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use sync::{Accessor, Directory, DirEntry, FileEntry, ReadDir};
|
||||
pub use sync::{Accessor, DirEntry, Directory, FileEntry, ReadDir};
|
||||
|
||||
/// Random access read implementation.
|
||||
pub trait ReadAt {
|
||||
@ -179,7 +179,7 @@ impl<T: Clone + ReadAt> DirectoryImpl<T> {
|
||||
data.set_len(len);
|
||||
let slice = std::slice::from_raw_parts_mut(
|
||||
data.as_mut_ptr() as *mut u8,
|
||||
len * size_of_val(&data[0]),
|
||||
len * size_of::<GoodbyeItem>(),
|
||||
);
|
||||
(&self.input as &dyn ReadAt)
|
||||
.read_exact_at(slice, self.table_offset())
|
||||
|
Loading…
Reference in New Issue
Block a user