Skip to content

Commit

Permalink
VoteState::deserialize_into: drop previous collections before deseria…
Browse files Browse the repository at this point in the history
…lizing
  • Loading branch information
alessandrod committed Jul 28, 2024
1 parent 3d74cde commit 02b33bb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sdk/program/src/vote/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ impl VoteState {
input: &[u8],
vote_state: &mut VoteState,
) -> Result<(), InstructionError> {
// assign empty collections to drop() old allocations if any
vote_state.votes = VecDeque::new();
vote_state.authorized_voters = AuthorizedVoters::default();
vote_state.epoch_credits = Vec::new();

VoteState::deserialize_into_ptr(input, vote_state as *mut VoteState)
}

Expand Down

0 comments on commit 02b33bb

Please sign in to comment.