From 9943fca6c7e7735c0e761ceb2ad40fbb9bd282e6 Mon Sep 17 00:00:00 2001 From: wizard701 <135021212+wizard701@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:42:30 +0530 Subject: [PATCH] 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. --- apps/remix-ide/contracts/ballot.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide/contracts/ballot.sol b/apps/remix-ide/contracts/ballot.sol index 1ebc747b44..aa49825fac 100644 --- a/apps/remix-ide/contracts/ballot.sol +++ b/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;