Fix the bug that int overflow can bypass the range check