File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -2989,11 +2989,11 @@ impl<T: Read> Read for Take<T> {
29892989 return Ok ( ( ) ) ;
29902990 }
29912991
2992- if self . limit <= buf. capacity ( ) as u64 {
2993- // if we just use an as cast to convert, limit may wrap around on a 32 bit target
2994- let limit = cmp :: min ( self . limit , usize :: MAX as u64 ) as usize ;
2992+ if self . limit < buf. capacity ( ) as u64 {
2993+ // The condition above guarantees that `self. limit` fits in `usize`.
2994+ let limit = self . limit as usize ;
29952995
2996- let extra_init = cmp:: min ( limit as usize , buf. init_ref ( ) . len ( ) ) ;
2996+ let extra_init = cmp:: min ( limit, buf. init_ref ( ) . len ( ) ) ;
29972997
29982998 // SAFETY: no uninit data is written to ibuf
29992999 let ibuf = unsafe { & mut buf. as_mut ( ) [ ..limit] } ;
You can’t perform that action at this time.
0 commit comments