Skip to content

Commit 7a61ea5

Browse files
committed
Reset StreamWrapper after calling mz_inflate / mz_deflate
1 parent f62ff42 commit 7a61ea5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ffi/c.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ impl InflateBackend for Inflate {
226226
self.inner.total_in += (raw.next_in as usize - input.as_ptr() as usize) as u64;
227227
self.inner.total_out += (raw.next_out as usize - output.as_ptr() as usize) as u64;
228228

229+
// reset these pointers so we don't accidentally read them later
230+
raw.next_in = ptr::null_mut();
231+
raw.avail_in = 0;
232+
raw.next_out = ptr::null_mut();
233+
raw.avail_out = 0;
234+
229235
match rc {
230236
MZ_DATA_ERROR | MZ_STREAM_ERROR => mem::decompress_failed(self.inner.msg()),
231237
MZ_OK => Ok(Status::Ok),
@@ -314,6 +320,12 @@ impl DeflateBackend for Deflate {
314320
self.inner.total_in += (raw.next_in as usize - input.as_ptr() as usize) as u64;
315321
self.inner.total_out += (raw.next_out as usize - output.as_ptr() as usize) as u64;
316322

323+
// reset these pointers so we don't accidentally read them later
324+
raw.next_in = ptr::null_mut();
325+
raw.avail_in = 0;
326+
raw.next_out = ptr::null_mut();
327+
raw.avail_out = 0;
328+
317329
match rc {
318330
MZ_OK => Ok(Status::Ok),
319331
MZ_BUF_ERROR => Ok(Status::BufError),

0 commit comments

Comments
 (0)