Skip to content

Commit

Permalink
Fix io::BufReader uses of read_buf
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Sep 23, 2024
1 parent 8472204 commit 57f279d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion std/src/io/buffered/bufreader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl<R: ?Sized + Read> Read for BufReader<R> {
let prev = cursor.written();

let mut rem = self.fill_buf()?;
rem.read_buf(cursor.reborrow())?;
rem.read_buf(cursor.reborrow())?; // actually never fails

self.consume(cursor.written() - prev); //slice impl of read_buf known to never unfill buf

Expand Down
4 changes: 3 additions & 1 deletion std/src/io/buffered/bufreader/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ impl Buffer {
buf.set_init(self.initialized);
}

reader.read_buf(buf.unfilled())?;
let result = reader.read_buf(buf.unfilled());

self.pos = 0;
self.filled = buf.len();
self.initialized = buf.init_len();

result?;
}
Ok(self.buffer())
}
Expand Down

0 comments on commit 57f279d

Please sign in to comment.