In Solidity, people use a SafeMath library to prevent overflow/underflow attack. So, I wonder what's the best way to prevent overflow/underflow attack for EOS contract. Is there an easy-to-use SafeMath library available?
EOS uses C ++, and C ++ assert can be used to check for overflow or underflow.
ex) assert( quantity + a.quantity >= a.quantity,"integer overflow adding token balance" );
See the link below for this.
Also, eosio provides eosio_assert to enable various assertions.