mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-25 17:33:28 +04:00
Don't create len=0 slices in iov
This commit is contained in:
parent
36a1ed98c8
commit
c0be01319b
@ -1644,6 +1644,8 @@ impl IoVecs {
|
||||
readv: bool,
|
||||
) -> Result<Self, SysError> {
|
||||
let iovs = vm.check_read_array(iov_ptr, iov_count)?.to_vec();
|
||||
let mut slices = vec![];
|
||||
slices.reserve(iovs.len());
|
||||
// check all bufs in iov
|
||||
for iov in iovs.iter() {
|
||||
// skip empty iov
|
||||
@ -1655,11 +1657,8 @@ impl IoVecs {
|
||||
} else {
|
||||
vm.check_read_array(iov.base, iov.len)?;
|
||||
}
|
||||
slices.push(slice::from_raw_parts_mut(iov.base, iov.len));
|
||||
}
|
||||
let slices = iovs
|
||||
.iter()
|
||||
.map(|iov| slice::from_raw_parts_mut(iov.base, iov.len))
|
||||
.collect();
|
||||
Ok(IoVecs(slices))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user