Fix an overflow checking bug uncovered when a 32 bit target is compiled