From dc833bcc6d4db6f1aed7c2c3c3e4ef3f508fda5d Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:07:28 +0900 Subject: [PATCH] :bug: fix #71 avoid free null pointer --- liblzma-sys/src/wasm_shim.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/liblzma-sys/src/wasm_shim.rs b/liblzma-sys/src/wasm_shim.rs index a216e75c..29bafc5c 100644 --- a/liblzma-sys/src/wasm_shim.rs +++ b/liblzma-sys/src/wasm_shim.rs @@ -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);