From 73fe4004075508ef808d5b63ef8fadc02024100c Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Fri, 5 Aug 2022 08:19:46 -0500 Subject: [PATCH] protect access to rent paying account vec (#26919) --- runtime/src/rent_paying_accounts_by_partition.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/src/rent_paying_accounts_by_partition.rs b/runtime/src/rent_paying_accounts_by_partition.rs index 286e5eebd5..9232677ac9 100644 --- a/runtime/src/rent_paying_accounts_by_partition.rs +++ b/runtime/src/rent_paying_accounts_by_partition.rs @@ -5,6 +5,10 @@ use { std::collections::HashSet, }; +lazy_static! { + pub static ref EMPTY_HASHSET: HashSet = HashSet::default(); +} + /// populated at startup with the accounts that were found that are rent paying. /// These are the 'possible' rent paying accounts. /// This set can never grow during runtime since it is not possible to create rent paying accounts now. @@ -45,7 +49,9 @@ impl RentPayingAccountsByPartition { &self, partition_end_index: PartitionIndex, ) -> &HashSet { - &self.accounts[partition_end_index as usize] + self.accounts + .get(partition_end_index as usize) + .unwrap_or(&EMPTY_HASHSET) } pub fn is_initialized(&self) -> bool { self.partition_count != 0