Skip to content

Commit

Permalink
🐛 fix alexcrichton#71 avoid free null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Oct 7, 2023
1 parent 9d10f97 commit dc833bc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions liblzma-sys/src/wasm_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub extern "C" fn rust_lzma_wasm_shim_calloc(nmemb: usize, size: usize) -> *mut

#[no_mangle]
pub unsafe extern "C" fn rust_lzma_wasm_shim_free(ptr: *mut c_void) {
if ptr == std::ptr::null_mut() {
return;
}
// layout is not actually used
let layout = Layout::from_size_align_unchecked(1, 1);
dealloc(ptr.cast(), layout);
Expand Down

0 comments on commit dc833bc

Please sign in to comment.