Fix some undefined behaviour: signed overflow and over shift left.

Caught by UndefinedBehaviourSanitizer.
This commit is contained in:
Jonathan G Rennison
2015-11-22 23:16:09 +00:00
parent 8e3d9a520c
commit ecf5943954
3 changed files with 3 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ int GreatestCommonDivisor(int a, int b)
*/
int DivideApprox(int a, int b)
{
int random_like = ((a + b) * (a - b)) % b;
int random_like = (((int64) (a + b)) * ((int64) (a - b))) % b;
int remainder = a % b;