Skip to content

Commit b3bc885

Browse files
committed
io: Avoid marking buffer as uninit when copying to BufWriter
1 parent c60865a commit b3bc885

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: std/src/io/copy.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,11 @@ impl<I: Write + ?Sized> BufferedWriterSpec for BufWriter<I> {
248248
Err(e) => return Err(e),
249249
}
250250
} else {
251+
// All the bytes that were already in the buffer are initialized,
252+
// treat them as such when the buffer is flushed.
253+
init += buf.len();
254+
251255
self.flush_buf()?;
252-
init = 0;
253256
}
254257
}
255258
}

0 commit comments

Comments
 (0)