From 0d0b849e85c2db5cbbf2ce7f2a569e64c1e887c1 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Sun, 15 Oct 2023 19:43:57 +0200 Subject: [PATCH] Fix the issue --- tokio/src/io/util/take.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tokio/src/io/util/take.rs b/tokio/src/io/util/take.rs index df2f61b9e60..ac1f2aef416 100644 --- a/tokio/src/io/util/take.rs +++ b/tokio/src/io/util/take.rs @@ -1,6 +1,7 @@ use crate::io::{AsyncBufRead, AsyncRead, ReadBuf}; use pin_project_lite::pin_project; +use std::convert::TryFrom; use std::pin::Pin; use std::task::{Context, Poll}; use std::{cmp, io}; @@ -85,7 +86,7 @@ impl AsyncRead for Take { } let me = self.project(); - let mut b = buf.take(*me.limit_ as usize); + let mut b = buf.take(usize::try_from(*me.limit_).unwrap_or(usize::MAX)); let buf_ptr = b.filled().as_ptr(); ready!(me.inner.poll_read(cx, &mut b))?;