The function returns 0 if the player is not found in the array which is not correct as in Solidity the array indices starts from zero that means the result will be wrong and the funds will be transferred to wrong participant.
The first participant which have index 0 will be returned through this function.
The function getActivePlayerIndex is incorrect as it does not handle the case where the first player's address is found correctly. It returns 0 when the first player is found in the array, which may lead to a false positive result indicating that the player's index is 0.
In Solidity, array indices start from 0, and if the function returns 0 for a player that is found in the first position of the array, it can be misleading and incorrect.
Here's my proof of test code that shows that the function is wrongly implemented:
Remix IDE, Hardhat
To make the function correct, one should consider returning a value that clearly indicates when the player is not found in the array. For example, you can return -1 or another suitable value to indicate that the player is not active or does not exist in the array.
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.