diff options
Diffstat (limited to 'tokio/src/io/async_read.rs')
-rw-r--r-- | tokio/src/io/async_read.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tokio/src/io/async_read.rs b/tokio/src/io/async_read.rs index d28280a5..24c1b4ef 100644 --- a/tokio/src/io/async_read.rs +++ b/tokio/src/io/async_read.rs @@ -123,7 +123,9 @@ pub trait AsyncRead { // Convert to `&mut [u8]` let b = &mut *(b as *mut [MaybeUninit<u8>] as *mut [u8]); - ready!(self.poll_read(cx, b))? + let n = ready!(self.poll_read(cx, b))?; + assert!(n <= b.len(), "Bad AsyncRead implementation, more bytes were reported as read than the buffer can hold"); + n }; buf.advance_mut(n); |