From bb7353c02afd7ff04c4a71cc2b114ed8a6136994 Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 27 Oct 2018 18:13:42 +0100 Subject: Codechange: Some more null checks --- src/pathfinder/follow_track.hpp | 8 ++++++-- src/train_cmd.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 70f148de3..0aec3951e 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -124,8 +124,12 @@ struct CFollowTrackT m_old_tile = old_tile; m_old_td = old_td; m_err = EC_NONE; - assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), IsRoadTT() ? RoadVehicle::From(m_veh)->compatible_roadtypes : 0)) & TrackdirToTrackdirBits(m_old_td)) != 0) || - (IsTram() && GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits + assert( + ((TrackStatusToTrackdirBits( + GetTileTrackStatus(m_old_tile, TT(), (IsRoadTT() && m_veh != NULL) ? RoadVehicle::From(m_veh)->compatible_roadtypes : 0) + ) & TrackdirToTrackdirBits(m_old_td)) != 0) || + (IsTram() && GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR) // Disable the assertion for single tram bits + ); m_exitdir = TrackdirToExitdir(m_old_td); if (ForcedReverse()) return true; if (!CanExitOldTile()) return false; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index b1eeab1bd..0672ac209 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -874,7 +874,7 @@ static void RemoveFromConsist(Train *part, bool chain = false) static void InsertInConsist(Train *dst, Train *chain) { /* We do not want to add something in the middle of an articulated part. */ - assert(dst->Next() == NULL || !dst->Next()->IsArticulatedPart()); + assert(dst != NULL && (dst->Next() == NULL || !dst->Next()->IsArticulatedPart())); chain->Last()->SetNext(dst->Next()); dst->SetNext(chain); -- cgit v1.2.3-54-g00ecf