From 486f7b76738a4a3664332fe42ff0ccc1b6f05c92 Mon Sep 17 00:00:00 2001 From: Jack May Date: Wed, 23 Mar 2022 17:03:01 -0700 Subject: [PATCH] use array access function (#23895) --- runtime/src/accounts.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 6d934e3946..24dabe3ff6 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -416,7 +416,13 @@ impl Accounts { error_counters: &mut ErrorCounters, ) -> Result> { let mut account_indices = Vec::new(); - let mut program_id = accounts[program_account_index].0; + let mut program_id = match accounts.get(program_account_index) { + Some(program_account) => program_account.0, + None => { + error_counters.account_not_found += 1; + return Err(TransactionError::ProgramAccountNotFound); + } + }; let mut depth = 0; while !native_loader::check_id(&program_id) { if depth >= 5 {