Skip to content

inflate::reset_keep: clear more fields #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions zlib-rs/src/inflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ pub fn uncompress<'a>(

let err = unsafe { inflate(stream, InflateFlush::NoFlush) };

if err != ReturnCode::Ok as _ {
if err != ReturnCode::Ok {
break err;
}
};

if !output.is_empty() {
dest_len_ptr = stream.total_out;
} else if stream.total_out != 0 && err == ReturnCode::BufError as _ {
} else if stream.total_out != 0 && err == ReturnCode::BufError {
left = 1;
}

Expand Down Expand Up @@ -1795,7 +1795,7 @@ pub fn init(stream: &mut z_stream, config: InflateConfig) -> ReturnCode {
ReturnCode::StreamError
};

if ret != ReturnCode::Ok as _ {
if ret != ReturnCode::Ok {
let ptr = stream.state;
stream.state = core::ptr::null_mut();
// SAFETY: we assume deallocation does not cause UB
Expand Down Expand Up @@ -1858,15 +1858,15 @@ pub fn reset(stream: &mut InflateStream) -> ReturnCode {
pub fn reset_keep(stream: &mut InflateStream) -> ReturnCode {
stream.total_in = 0;
stream.total_out = 0;
// stream.state.total = 0;
stream.state.total = 0;

stream.msg = core::ptr::null_mut();

let state = &mut stream.state;

if state.wrap != 0 {
// to support ill-conceived Java test suite
// stream.adler = state.wrap & 1;
// to support ill-conceived Java test suite
stream.adler = (state.wrap & 1) as _;
}

state.mode = Mode::Head;
Expand All @@ -1876,7 +1876,7 @@ pub fn reset_keep(stream: &mut InflateStream) -> ReturnCode {
state.havedict = false;
state.flags = -1;
state.dmax = 32768;
// state.head = NULL;
state.head = None;
state.bit_reader = BitReader::new(&[]);

state.next = 0;
Expand Down Expand Up @@ -2006,7 +2006,7 @@ pub fn sync(stream: &mut InflateStream) -> ReturnCode {
let state = &mut stream.state;

if stream.avail_in == 0 && state.bit_reader.bits_in_buffer() < 8 {
return ReturnCode::BufError as _;
return ReturnCode::BufError;
}
/* if first time, start search in bit buffer */
if !matches!(state.mode, Mode::Sync) {
Expand All @@ -2028,7 +2028,7 @@ pub fn sync(stream: &mut InflateStream) -> ReturnCode {

/* return no joy or set up to restart inflate() on a new block */
if state.have != 4 {
return ReturnCode::DataError as _;
return ReturnCode::DataError;
}

if state.flags == -1 {
Expand All @@ -2049,7 +2049,7 @@ pub fn sync(stream: &mut InflateStream) -> ReturnCode {
stream.state.flags = flags;
stream.state.mode = Mode::Type;

ReturnCode::Ok as _
ReturnCode::Ok
}

/*
Expand Down
Loading