]> git.tdb.fi Git - r2c2.git/commitdiff
Check that occupied_track is not null before accessing it
authorMikko Rasa <tdb@tdb.fi>
Sun, 30 Mar 2014 16:36:47 +0000 (19:36 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 30 Mar 2014 16:36:47 +0000 (19:36 +0300)
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.

source/libr2c2/trainrouteplanner.cpp

index e813b366fe88a4829d4cc155f9d731d41108d461..3f8739347d455405f1f2a6fef03c6b2c02c5e3a9 100644 (file)
@@ -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;
 }