Skip to content

Commit

Permalink
Added warning around code with reference to uninit bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Henry-Mantilla committed Sep 3, 2019
1 parent 815dec9 commit 23c76ff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libstd/io/mod.rs
Expand Up @@ -371,6 +371,14 @@ where
loop {
if g.len == g.buf.len() {
unsafe {
// FIXME(danielhenrymantilla): #42788
//
// - This creates a (mut) reference to a slice of
// _uninitialized integers_.
//
// - This having defined behavior is **unstable**:
// it could become UB in the future,
// at which point it would have be changed.
g.buf.reserve(reservation_size(r));
let capacity = g.buf.capacity();
g.buf.set_len(capacity);
Expand Down

0 comments on commit 23c76ff

Please sign in to comment.