Skip to content

Commit 390df29

Browse files
committed
Refine the status handing in version 1
1 parent 44e5f0c commit 390df29

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
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 = "woff"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2021"
55
license = "Apache-2.0/MIT"
66
authors = ["Ivan Ukhov <ivan.ukhov@gmail.com>"]

src/version1/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub fn compress(data: &[u8], major_version: usize, minor_version: usize) -> Opti
1818
&mut status,
1919
)
2020
};
21-
debug_assert_eq!(status, 0);
2221
finalize(data, size, status)
2322
}
2423

@@ -28,12 +27,12 @@ pub fn decompress(data: &[u8]) -> Option<Vec<u8>> {
2827
let mut status = 0;
2928
let data =
3029
unsafe { ffi::woffDecode(data.as_ptr() as _, data.len() as _, &mut size, &mut status) };
31-
debug_assert_eq!(status, 0);
3230
finalize(data, size, status)
3331
}
3432

3533
fn finalize(data: *const u8, size: u32, status: u32) -> Option<Vec<u8>> {
36-
if !data.is_null() && status == 0 {
34+
debug_assert_eq!(status & 0xFF, 0);
35+
if !data.is_null() && status & 0xFF == 0 {
3736
let mut buffer = Vec::with_capacity(size as _);
3837
unsafe {
3938
std::ptr::copy_nonoverlapping(data, buffer.as_mut_ptr(), size as _);

0 commit comments

Comments
 (0)