Description
In the RankedChoice.sol::selectPresident
function, the s_candidateList expands dynamically as new candidates are ranked by voters. If all 100 voters each rank 10 different candidates, the list could grow to 1,000 candidates. This excessive growth could result in gas exhaustion or inefficient execution, especially during the nested loops in the selectPresident and _selectPresidentRecursive functions, where the entire list is processed. As the number of candidates increases, so does the likelihood of exceeding gas limits, leading to potential transaction failures or delays in election results.
Recommended mitigation
Consider adding a reasonable upper limit on the number of unique candidates that can be added. This can be done by ensuring that no more than a predefined number of unique candidates are allowed, preventing uncontrolled growth of the list.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.