Skip to content
Snippets Groups Projects
Commit 09d31132 authored by Alexandre Bury's avatar Alexandre Bury Committed by ticki
Browse files

Protects AsyncReader::read against empty buffer. (#65)

Move the check to the beginning of the loop to protect against empty buffer.
parent 2d625d8c
No related branches found
No related tags found
No related merge requests found
......@@ -51,14 +51,14 @@ impl Read for AsyncReader {
let mut total = 0;
loop {
if total >= buf.len() {
break;
}
match self.recv.try_recv() {
Ok(Ok(b)) => {
buf[total] = b;
total += 1;
if total == buf.len() {
break;
}
},
Ok(Err(e)) => return Err(e),
Err(_) => break,
......
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