Skip to content

Commit

Permalink
fix: deallocate with correct amount of bytes (#54)
Browse files Browse the repository at this point in the history
dlmalloc-rs bundled with recent versions of Rust (1.78.0 and later) has
started to validate the size of deallocated memory blocks.

alexcrichton/dlmalloc-rs@74fbdb5
rust-lang/rust@9b73db3
  • Loading branch information
kateinoigakukun authored Apr 30, 2024
1 parent 45a4a3f commit 861233d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 1 deletion.
Binary file modified lib/package.wasm
Binary file not shown.
Binary file modified lib/virtual_adapter.debug.wasm
Binary file not shown.
Binary file modified lib/virtual_adapter.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion virtual-adapter/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl StaticIndexEntry {
);
let bytes = unsafe { slice::from_raw_parts(data, read_len) };
let vec = bytes.to_vec();
unsafe { std::alloc::dealloc(data, Layout::from_size_align(1, 4).unwrap()) };
unsafe { std::alloc::dealloc(data, Layout::from_size_align(read_len, 4).unwrap()) };
offset.set(offset.get() + read_len as u64);
Ok(vec)
}
Expand Down

0 comments on commit 861233d

Please sign in to comment.