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> {
2989
2989
return Ok ( ( ) ) ;
2990
2990
}
2991
2991
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 ;
2995
2995
2996
- let extra_init = cmp:: min ( limit as usize , buf. init_ref ( ) . len ( ) ) ;
2996
+ let extra_init = cmp:: min ( limit, buf. init_ref ( ) . len ( ) ) ;
2997
2997
2998
2998
// SAFETY: no uninit data is written to ibuf
2999
2999
let ibuf = unsafe { & mut buf. as_mut ( ) [ ..limit] } ;
You can’t perform that action at this time.
0 commit comments