Fix a potential integer overflow