Skip to content

Commit 1910467

Browse files
committed
finish brotli output when into_inner is called
1 parent a826cf1 commit 1910467

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "brotli"
3-
version = "3.2.0"
3+
version = "3.2.1"
44
authors = ["Daniel Reiter Horn <danielrh@dropbox.com>", "The Brotli Authors"]
55
description = "A brotli compressor and decompressor that with an interface avoiding the rust stdlib. This makes it suitable for embedded devices and kernels. It is designed with a pluggable allocator so that the standard lib's allocator may be employed. The default build also includes a stdlib allocator and stream interface. Disable this with --features=no-stdlib. All included code is safe."
66
license = "BSD-3-Clause/MIT"

src/enc/writer.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ CompressorWriterCustomIo<ErrType, W, BufferType, Alloc>
213213
self.output.as_ref().unwrap()
214214
}
215215
pub fn into_inner(mut self) -> W {
216+
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
217+
Ok(_) => {},
218+
Err(_) => {},
219+
}
216220
core::mem::replace(&mut self.output, None).unwrap()
217221
}
218222
}
@@ -223,9 +227,11 @@ impl<ErrType,
223227
Alloc: BrotliAlloc> Drop for
224228
CompressorWriterCustomIo<ErrType, W, BufferType, Alloc> {
225229
fn drop(&mut self) {
226-
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
227-
Ok(_) => {},
230+
if self.output.is_some() {
231+
match self.flush_or_close(BrotliEncoderOperation::BROTLI_OPERATION_FINISH) {
232+
Ok(_) => {},
228233
Err(_) => {},
234+
}
229235
}
230236
BrotliEncoderDestroyInstance(&mut self.state);
231237
}

0 commit comments

Comments
 (0)