Respect RefCell when calling invoke (#12858) (#12891)

* Respect RefCell when calling invoke

* nudge

(cherry picked from commit 969f7b015b)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-15 02:15:36 +00:00
committed by GitHub
parent ceeeb3c9dd
commit bc96332899
3 changed files with 157 additions and 13 deletions

View File

@@ -16,6 +16,22 @@ pub fn invoke_signed(
account_infos: &[AccountInfo],
signers_seeds: &[&[&[u8]]],
) -> ProgramResult {
// Check that the account RefCells are consistent with the request
for account_meta in instruction.accounts.iter() {
for account_info in account_infos.iter() {
if account_meta.pubkey == *account_info.key {
if account_meta.is_writable {
let _ = account_info.try_borrow_mut_lamports()?;
let _ = account_info.try_borrow_mut_data()?;
} else {
let _ = account_info.try_borrow_lamports()?;
let _ = account_info.try_borrow_data()?;
}
break;
}
}
}
let result = unsafe {
sol_invoke_signed_rust(
instruction as *const _ as *const u8,