From: Mikko Rasa Date: Sat, 21 Feb 2015 23:52:44 +0000 (+0200) Subject: Don't go past end of allocation when checking blocks for a signal X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4655bb74f9d6d7f6db8fca9e22721e6c0e1ada12;p=r2c2.git Don't go past end of allocation when checking blocks for a signal --- diff --git a/source/libr2c2/signal.cpp b/source/libr2c2/signal.cpp index 7aa9994..02a07d7 100644 --- a/source/libr2c2/signal.cpp +++ b/source/libr2c2/signal.cpp @@ -107,12 +107,16 @@ void Signal::tick(const Time::TimeDelta &) if(check_allocated_blocks) { unsigned n_blocks = 0; - BlockIter iter = block.next(); - while(iter && iter->get_train()==train) + const Block *last = train->get_block_allocator().last().block(); + if(block.block()!=last) { - if(iter->get_sensor_address()) - ++n_blocks; - iter = iter.next(); + BlockIter iter = block.next(); + while(iter && iter->get_train()==train && iter.block()!=last) + { + if(iter->get_sensor_address()) + ++n_blocks; + iter = iter.next(); + } } check_allocated_blocks = false;