Additional Require Check

Added a check in the vote function to ensure that the proposal index is within the range of the proposals array. This prevents out-of-bounds errors.
pull/5370/head
wizard701 5 months ago committed by Aniket
parent 922b65a958
commit c3d29c52d1
  1. 1
      apps/remix-ide/contracts/ballot.sol

@ -101,6 +101,7 @@ contract Ballot {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
require(proposal < proposals.length, "Invalid proposal index.");
sender.voted = true;
sender.vote = proposal;

Loading…
Cancel
Save