mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +00:00
fix(c-api) Ensure that uninitialized boxed vec are zeroed.
This patch updates how `wasm_$name_vec_new_uninitialized` creates the vector. The vector is now fully allocated with `null` pointer for each item, instead of having an empty vector with the initial capacity set to `length`. That way, we are sure the vector is zeroed correctly.
This commit is contained in:
@@ -326,7 +326,7 @@ int main() {
|
||||
```"]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new_uninitialized>](out: *mut [<wasm_ $name _vec_t>], length: usize) {
|
||||
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = Vec::with_capacity(length);
|
||||
let mut bytes: Vec<*mut [<wasm_ $name _t>]> = vec![::std::ptr::null_mut(); length];
|
||||
let pointer = bytes.as_mut_ptr();
|
||||
|
||||
(*out).data = pointer;
|
||||
|
||||
Reference in New Issue
Block a user