Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reconstruct result buffer #2813

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions crates/vm_env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(rustdoc::private_intra_doc_links)]

use std::mem::ManuallyDrop;

use borsh::BorshDeserialize;
use namada_core::internal::{HostEnvResult, KeyVal};

Expand Down Expand Up @@ -276,16 +274,10 @@ pub fn read_from_buffer(
if HostEnvResult::is_fail(read_result) {
None
} else {
let result: Vec<u8> = Vec::with_capacity(read_result as _);
// The `result` will be dropped from the `target`, which is
// reconstructed from the same memory
let result = ManuallyDrop::new(result);
let result = vec![0u8; read_result as _];
let offset = result.as_slice().as_ptr() as u64;
unsafe { result_buffer(offset) };
let target = unsafe {
Vec::from_raw_parts(offset as _, read_result as _, read_result as _)
};
Some(target)
Some(result)
}
}

Expand Down
Loading