File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -384,14 +384,15 @@ where
384384 }
385385 }
386386
387- match r. read ( & mut g. buf [ g. len ..] ) {
387+ let buf = & mut g. buf [ g. len ..] ;
388+ match r. read ( buf) {
388389 Ok ( 0 ) => return Ok ( g. len - start_len) ,
389390 Ok ( n) => {
390391 // We can't let g.len overflow which would result in the vec shrinking when the function returns. In
391392 // particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary.
392393 // The minimal check would just be a checked_add, but this assert is a bit more precise and should be
393394 // just about the same cost.
394- assert ! ( n <= g . buf. len( ) - g . len ) ;
395+ assert ! ( n <= buf. len( ) ) ;
395396 g. len += n;
396397 }
397398 Err ( ref e) if e. kind ( ) == ErrorKind :: Interrupted => { }
You can’t perform that action at this time.
0 commit comments