Also prevent integer overflow if MaximumDistance == UINT_MAX. This is a follow-up to 6ad1b40951
6ad1b40951