Remove overflow opportunities (#13649) (#13650)

(cherry picked from commit a7bed62af0)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
mergify[bot]
2020-11-17 20:15:43 +00:00
committed by GitHub
parent b0523dc236
commit 0aab403cbc

View File

@ -909,7 +909,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);
@ -928,7 +928,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 {