Skip to content

Commit

Permalink
fix wouldblock
Browse files Browse the repository at this point in the history
  • Loading branch information
quininer committed Feb 15, 2019
1 parent 844830c commit 6512539
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/gz/bufread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,11 @@ impl<R: BufRead> Read for GzDecoder<R> {
GzState::Header { state, flag, hasher } => {
match read_gz_header2(reader.get_mut().get_mut(), state, header, flag, hasher) {
Ok(_) => next = Next::Body,
Err(ref err) if io::ErrorKind::WouldBlock == err.kind() => (),
Err(err) => next = Next::Err(err)
Err(err) => if io::ErrorKind::WouldBlock == err.kind() {
return Err(err);
} else {
next = Next::Err(err);
}
}
},
GzState::Body => {
Expand All @@ -560,14 +563,14 @@ impl<R: BufRead> Read for GzDecoder<R> {
}
} else {
let (crc, amt) = finish(buf);

if crc != reader.crc().sum() {
return Err(corrupt());
}
if amt != reader.crc().amount() {
return Err(corrupt());
next = Next::Err(corrupt());
} else if amt != reader.crc().amount() {
next = Next::Err(corrupt());
} else {
next = Next::End;
}

next = Next::End;
},
GzState::Err(err) => next = Next::Err(mem::replace(err, io::ErrorKind::Other.into())),
GzState::End => return Ok(0)
Expand Down

0 comments on commit 6512539

Please sign in to comment.