From a7bed62af00f0d82fac1f6cae9c61fabe97a7d24 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 17 Nov 2020 12:01:11 -0700 Subject: [PATCH] Remove overflow opportunities (#13649) --- programs/stake/src/stake_state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index 099a40411a..cdf71eaa08 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -910,7 +910,7 @@ impl<'a> StakeAccount for KeyedAccount<'a> { // verify full withdrawal can cover rent in new split account || (lamports < split_rent_exempt_reserve && lamports == self.lamports()?) // verify enough lamports left in previous stake and not full withdrawal - || (lamports > self.lamports()? - meta.rent_exempt_reserve + || (lamports + meta.rent_exempt_reserve > self.lamports()? && lamports != self.lamports()?) { return Err(InstructionError::InsufficientFunds); @@ -929,7 +929,7 @@ impl<'a> StakeAccount for KeyedAccount<'a> { // account, this prevents any magic activation of stake by prefunding the // split account. ( - lamports - meta.rent_exempt_reserve, + lamports.saturating_sub(meta.rent_exempt_reserve), lamports - split_rent_exempt_reserve, ) } else {