Merge pull request #346 from ethereum/rust-declare

rust: allow empty code in evmc_execute()
This commit is contained in:
Alex Beregszaszi 2019-07-04 18:08:53 +01:00 committed by GitHub
commit cab1073407
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -337,10 +337,10 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
{
use evmc_vm::EvmcVm;
assert!(!msg.is_null());
assert!(!context.is_null());
assert!(!instance.is_null());
assert!(!code.is_null());
// TODO: context is optional in case of the "precompiles" capability
assert!(!context.is_null());
assert!(!msg.is_null());
let execution_context = unsafe {
::evmc_vm::ExecutionContext::new(
@ -349,8 +349,14 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream {
)
};
let code_ref: &[u8] = unsafe {
let empty_code = [0u8;0];
let code_ref: &[u8] = if code.is_null() {
assert_eq!(code_size, 0);
&empty_code
} else {
unsafe {
::std::slice::from_raw_parts(code, code_size)
}
};
let container = unsafe {