rust: unwind execution panics in evmc-declare

This commit is contained in:
Alex Beregszaszi 2019-06-06 00:38:07 +02:00
parent 199140cb35
commit 4d07d1a340
1 changed files with 9 additions and 1 deletions

View File

@ -363,7 +363,15 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance) ::evmc_vm::EvmcContainer::<#type_name_ident>::from_ffi_pointer(instance)
}; };
let result = container.execute(code_ref, &execution_context); let result = ::std::panic::catch_unwind(|| {
container.execute(code_ref, &execution_context)
});
let result = if result.is_err() {
::evmc_vm::ExecutionResult::new(::evmc_vm::ffi::evmc_status_code::EVMC_INTERNAL_ERROR, 0, None)
} else {
result.unwrap()
};
unsafe { unsafe {
::evmc_vm::EvmcContainer::into_ffi_pointer(container); ::evmc_vm::EvmcContainer::into_ffi_pointer(container);