Due to a mishandling of else if statement in the TwentyOne::call function, the player wins the game even if they should not.
In TwentyOne::call function, in order to determine the winner the following logic is used:
if dealer's hand is over 21 => player wins
else if player's hand is greater than the dealer's => player wins (here's the bug)
else, player loses
The problem with this logic is that in that else if statement, player draws another card, and thus, in that draw, player's hand can go over 21, leading to a loss.
Here's the function in question
There's another bug relating to the dealer being called as msg.sender (same as the player, but I submitted that bug in another issue).
Player wins when they should not.
Manual review
Change else if (playerHand > dealerHand)
to else if (playerHand <= 21 && playerHand > dealerHand
)
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.