mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
fs: fill the destination buffer with 0s for MockFile::read() (#7596)
This commit is contained in:
parent
510b9ea9dc
commit
94b6df699b
@ -56,6 +56,13 @@ mock! {
|
||||
|
||||
impl Read for MockFile {
|
||||
fn read(&mut self, dst: &mut [u8]) -> io::Result<usize> {
|
||||
// Placate Miri. Tokio will call this method with an uninitialized
|
||||
// buffer, which is ok because std::io::Read::read implementations don't usually read
|
||||
// from their input buffers. But Mockall 0.12-0.13 will try to Debug::fmt the
|
||||
// buffer, even if there is no failure, triggering an uninitialized data access alert from
|
||||
// Miri. Initialize the data here just to prevent those Miri alerts.
|
||||
// This can be removed after upgrading to Mockall 0.14.
|
||||
dst.fill(0);
|
||||
self.inner_read(dst)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user