Fixed #1751 (Undefined Behavior: Signed integer overflow)