Submitted by hickuphh3, also found by shw, jonah1005, 0xRajeev and cmichel
In the _approve function, if the allowance passed in is type(uint256).max, nothing happens (ie. allowance will still remain at previous value). Contract integrations (DEXes for example) tend to hardcode this value to set maximum allowance initially, but this will result in zero allowance given instead.
This also makes the comment // No need to re-approve if already max misleading, because the max allowance attainable is type(uint256).max - 1, and re-approval does happen in this case.
This affects the approveAndCall implementation since it uses type(uint256).max as the allowance amount, but the resulting allowance set is zero.
Recommend keeping it simple and removing the condition.
SamusElderg (Spartan) confirmed:
ghoul-sol (judge) commented:
