Skip to content

Commit 5fda63f

Browse files
committed
fix bug in inflate::uncompress
1 parent 6941d17 commit 5fda63f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

zlib-rs/src/inflate.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,13 @@ pub fn uncompress<'a>(
163163

164164
let mut stream = z_stream {
165165
next_in: input.as_ptr() as *mut u8,
166-
avail_in: input.len() as _,
167-
total_in: 0,
168-
next_out: dest,
169-
avail_out: output.len() as _,
170-
total_out: 0,
171-
msg: core::ptr::null_mut(),
172-
state: core::ptr::null_mut(),
166+
avail_in: 0,
167+
173168
zalloc: None,
174169
zfree: None,
175170
opaque: core::ptr::null_mut(),
176-
data_type: 0,
177-
adler: 0,
178-
reserved: 0,
171+
172+
..z_stream::default()
179173
};
180174

181175
let err = init(&mut stream, config);
@@ -196,7 +190,7 @@ pub fn uncompress<'a>(
196190
left -= stream.avail_out as u64;
197191
}
198192

199-
if stream.avail_out == 0 {
193+
if stream.avail_in == 0 {
200194
stream.avail_in = Ord::min(len, u32::MAX as u64) as u32;
201195
len -= stream.avail_in as u64;
202196
}

0 commit comments

Comments
 (0)