914: Fix bug in getting a Memory from export in C API r=Hywan a=MarkMcCaskey

I believe this fixes the non-deterministic crashing on OSX in `go-ext-wasm`

Co-authored-by: Mark McCaskey <mark@wasmer.io>
This commit is contained in:
bors[bot]
2019-10-30 11:34:20 +00:00
committed by GitHub

View File

@ -13,7 +13,7 @@ use crate::{
};
use libc::{c_int, c_uint};
use std::{ptr, slice};
use wasmer_runtime::{Instance, Memory, Module, Value};
use wasmer_runtime::{Instance, Module, Value};
use wasmer_runtime_core::{export::Export, module::ExportIndex};
/// Intermediate representation of an `Export` instance that is
@ -384,7 +384,8 @@ pub unsafe extern "C" fn wasmer_export_to_memory(
let export = &named_export.export;
if let Export::Memory(exported_memory) = export {
*memory = exported_memory as *const Memory as *mut wasmer_memory_t;
let mem = Box::new(exported_memory.clone());
*memory = Box::into_raw(mem) as *mut wasmer_memory_t;
wasmer_result_t::WASMER_OK
} else {
update_last_error(CApiError {