Skip to content

Commit

Permalink
address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Jul 18, 2024
1 parent 13c185d commit a016800
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sdk/program/src/vote/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,6 @@ impl VoteState {
_ => Err(InstructionError::InvalidAccountData),
}?;

// if cursor overruns the input, it produces null bytes and continues to advance `position`
// this check ensures we do not accept such a malformed input erroneously
if cursor.position() > input.len() as u64 {
return Err(InstructionError::InvalidAccountData);
}

Ok(())
}

Expand Down Expand Up @@ -1177,7 +1171,14 @@ mod tests {
let test_res = VoteState::deserialize_into(&raw_data, &mut test_vote_state);
let bincode_res = bincode::deserialize::<VoteStateVersions>(&raw_data);

assert_eq!(test_res.is_ok(), bincode_res.is_ok());
if test_res.is_err() {
assert!(bincode_res.is_err());
} else {
assert_eq!(
VoteStateVersions::new_current(test_vote_state),
bincode_res.unwrap()
);
}
}
}

Expand Down

0 comments on commit a016800

Please sign in to comment.