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

@@ -61,7 +61,7 @@ static inline bool IsValidTrackdirForRoadVehicle(Trackdir trackdir)
*/
static inline bool IsValidTrackdir(Trackdir trackdir)
{
return (1 << trackdir & TRACKDIR_BIT_MASK) != 0;
return trackdir < TRACKDIR_END && ((1 << trackdir & TRACKDIR_BIT_MASK) != 0);
}
/**