use checkedint to check overflow
Merge pull request #3949 from WalterBright/overflow-check

use checkedint to check overflow