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

@@ -8322,7 +8322,7 @@ static void CalculateRefitMasks()
}
/* Clear invalid cargoslots (from default vehicles or pre-NewCargo GRFs) */
if (!HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID;
if (ei->cargo_type != CT_INVALID && !HasBit(_cargo_mask, ei->cargo_type)) ei->cargo_type = CT_INVALID;
/* Ensure that the vehicle is either not refittable, or that the default cargo is one of the refittable cargoes.
* Note: Vehicles refittable to no cargo are handle differently to vehicle refittable to a single cargo. The latter might have subtypes. */