Skip to content

Commit 494f082

Browse files
committed
Fix update of bytes read in the encoder state machine.
Previously we were not updating the number of bytes read: we were just changing the local binding of `read`. This means that read was always zero and therefore the encoder never flushed.
1 parent 0370b47 commit 494f082

File tree

1 file changed

+4
-4
lines changed
  • crates/async-compression/src/generic/bufread

1 file changed

+4
-4
lines changed

crates/async-compression/src/generic/bufread/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ impl Encoder {
3434
mut input: Option<&mut PartialBuffer<&[u8]>>,
3535
) -> ControlFlow<Result<()>> {
3636
loop {
37-
self.state = match self.state {
38-
State::Encoding(mut read) => match input.as_mut() {
37+
self.state = match &mut self.state {
38+
State::Encoding(read) => match input.as_mut() {
3939
None => {
40-
if read == 0 {
40+
if *read == 0 {
4141
if output.written().is_empty() {
4242
// Poll for more data
4343
break;
@@ -56,7 +56,7 @@ impl Encoder {
5656
return ControlFlow::Break(Err(err));
5757
}
5858

59-
read += input.written().len();
59+
*read += input.written().len();
6060

6161
// Poll for more data
6262
break;

0 commit comments

Comments
 (0)