Skip to content
Snippets Groups Projects
Commit bf3c4225 authored by morenonatural's avatar morenonatural
Browse files

shrink result to actual number of bytes read once on return

parent 161d5312
No related branches found
No related tags found
No related merge requests found
......@@ -304,15 +304,17 @@ where
written_total += written_in_this_loop;
// in case we read less than `buffer_window_size` we need to shrink result
// because otherwise we'll return those un-read 0s
if written_total < result.len() {
result.resize(written_total, 0);
}
// exit conditions below
if written_in_this_loop == 0 {
/*
in case we read less than `buffer_window_size` in last `read`
we need to shrink result because otherwise we'll return those
un-read 0s
*/
if written_total < result.len() {
result.resize(written_total, 0);
}
return Ok(());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment