Fixed issue when there are no WebAssembly functions to allocate in memory

This commit is contained in:
Syrus Akbary
2018-10-15 11:51:38 +02:00
parent 69efaaaddd
commit ad31e295dd

View File

@ -107,6 +107,10 @@ impl Instance {
context_and_offsets.push((func_context, code_size_offset));
}
// We only want to allocate in memory if there is more than
// 0 functions. Otherwise reserving a 0-sized memory
// cause a panic error
if total_size > 0 {
// Allocate the total memory for this functions
let map = MmapMut::map_anon(total_size).unwrap();
let region_start = map.as_ptr();
@ -132,6 +136,7 @@ impl Instance {
.expect("unable to make memory readable+executable");
}
}
}
// Instantiate tables
{