Problem:
Vec::from_raw_parts assumes the pointer is valid:
The function assumes the provided pointer is a valid, non-null pointer previously allocated by a Rust allocator.
If ptr was not allocated using the Rust allocator (e.g., allocated via a foreign allocator or system calls), calling Vec::from_raw_parts is undefined behavior.
Steps to Reproduce:
Provide a foreign-allocated pointer (e.g., using malloc or other allocators) to dealloc, as shown below:
Additional Context:
Improper use of unsafe functions like Vec::from_raw_parts can lead to serious issues in safety-critical applications. Ensuring correctness when dealing with raw pointers and unsafe code is crucial in Rust to maintain memory safety guarantees.
Description The dealloc function contains an unsound implementation that can lead to undefined behavior. Specifically, the issue arises from the improper use of Vec::from_raw_parts to deallocate memory. https://github.com/flaneur2020/pua-lang/blob/cbaf8e2ca1abc3797c332afcc9103c567ee16002/src/wasm/main.rs#L61
Problem: Vec::from_raw_parts assumes the pointer is valid: The function assumes the provided pointer is a valid, non-null pointer previously allocated by a Rust allocator. If ptr was not allocated using the Rust allocator (e.g., allocated via a foreign allocator or system calls), calling Vec::from_raw_parts is undefined behavior.
Steps to Reproduce: Provide a foreign-allocated pointer (e.g., using malloc or other allocators) to dealloc, as shown below:
Result
Additional Context: Improper use of unsafe functions like Vec::from_raw_parts can lead to serious issues in safety-critical applications. Ensuring correctness when dealing with raw pointers and unsafe code is crucial in Rust to maintain memory safety guarantees.