From 57f279d91b7deea8958b7718cfc720974bd2a11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Wed, 22 May 2024 11:41:19 +0200 Subject: [PATCH] Fix `io::BufReader` uses of `read_buf` --- std/src/io/buffered/bufreader.rs | 2 +- std/src/io/buffered/bufreader/buffer.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/std/src/io/buffered/bufreader.rs b/std/src/io/buffered/bufreader.rs index e51dde994de45..438df70505b20 100644 --- a/std/src/io/buffered/bufreader.rs +++ b/std/src/io/buffered/bufreader.rs @@ -349,7 +349,7 @@ impl Read for BufReader { 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 diff --git a/std/src/io/buffered/bufreader/buffer.rs b/std/src/io/buffered/bufreader/buffer.rs index 1bf84d8bef312..68b024bb98aac 100644 --- a/std/src/io/buffered/bufreader/buffer.rs +++ b/std/src/io/buffered/bufreader/buffer.rs @@ -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()) }