diff --git a/library/std/src/io/copy.rs b/library/std/src/io/copy.rs index a75dbc76278..6ab96662305 100644 --- a/library/std/src/io/copy.rs +++ b/library/std/src/io/copy.rs @@ -103,7 +103,7 @@ impl BufferedCopySpec for BufWriter { return Ok(len); } - init = read_buf.initialized_len(); + init = read_buf.initialized_len() - bytes_read; // SAFETY: ReadBuf guarantees all of its filled bytes are init unsafe { buf.set_len(buf.len() + bytes_read) };