From: Mikko Rasa Date: Sun, 30 Mar 2014 16:36:47 +0000 (+0300) Subject: Check that occupied_track is not null before accessing it X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3d5779e12351547dded382f2d05d3f3f037dbcfd;p=r2c2.git Check that occupied_track is not null before accessing it This could only happen if an exception is thrown from TrainRoutingState constructor, but the resulting segfault can act as a red herring and distract from the actual cause. --- diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index e813b36..3f87393 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -175,7 +175,7 @@ TrainRoutePlanner::TrainRoutingState::TrainRoutingState(const TrainRoutingState TrainRoutePlanner::TrainRoutingState::~TrainRoutingState() { - if(!--occupied_tracks->refcount) + if(occupied_tracks && !--occupied_tracks->refcount) delete occupied_tracks; }