@@ -354,39 +354,39 @@ impl<'a, 'ix_data> InvokeContext<'a, 'ix_data> {
354354 fn verify_instruction_accounts ( & mut self , signers : & [ Pubkey ] ) -> Result < ( ) , InstructionError > {
355355 let instruction_context = self . transaction_context . get_current_instruction_context ( ) ?;
356356 let next_context = self . transaction_context . get_next_instruction_context ( ) ?;
357- let instruction_accounts = next_context. instruction_accounts ( ) ;
358- for current_index in 0 ..instruction_accounts. len ( ) {
359- let instruction_account = instruction_accounts. get ( current_index) . unwrap ( ) ;
360-
357+ let callee_instruction_accounts = next_context. instruction_accounts ( ) ;
358+ for ( idx, callee_account) in callee_instruction_accounts. iter ( ) . enumerate ( ) {
361359 if next_context
362- . is_instruction_account_duplicate ( current_index as u16 ) ?
360+ . is_instruction_account_duplicate ( idx as u16 ) ?
363361 . is_some ( )
364362 {
365363 continue ;
366364 }
367365
368366 let index_in_caller = instruction_context
369- . get_index_of_account_in_instruction ( instruction_account . index_in_transaction ) ?;
367+ . get_index_of_account_in_instruction ( callee_account . index_in_transaction ) ?;
370368
371369 // The account passed down to the instruction is supposed to be present in the caller
372370 let account_key =
373371 instruction_context. get_key_of_instruction_account ( index_in_caller) ?;
374372
375- // get_index_of_account_in_instruction has already checked if the index is valid.
376373 let caller_instruction_account = instruction_context
377374 . instruction_accounts ( )
378375 . get ( index_in_caller as usize )
379- . unwrap ( ) ;
376+ . expect (
377+ "get_index_of_account_in_instruction above has already checked if the index \
378+ is valid.",
379+ ) ;
380380
381381 // Readonly in caller cannot become writable in callee
382- if instruction_account . is_writable ( ) && !caller_instruction_account. is_writable ( ) {
382+ if callee_account . is_writable ( ) && !caller_instruction_account. is_writable ( ) {
383383 ic_msg ! ( self , "{}'s writable privilege escalated" , account_key, ) ;
384384 return Err ( InstructionError :: PrivilegeEscalation ) ;
385385 }
386386
387387 // To be signed in the callee,
388388 // it must be either signed in the caller or by the program
389- if instruction_account . is_signer ( )
389+ if callee_account . is_signer ( )
390390 && !( caller_instruction_account. is_signer ( ) || signers. contains ( account_key) )
391391 {
392392 ic_msg ! ( self , "{}'s signer privilege escalated" , account_key, ) ;
0 commit comments