From ff5e34ee70775e51915e7d40abf51ff0e644e6e1 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Wed, 30 Nov 2011 18:48:38 +0100 Subject: [PATCH] Fixing segfaults when restrictions list was empty. See ticket #34 --- Contractor/EdgeBasedGraphFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index e7499c722..b461ddf24 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -103,7 +103,7 @@ void EdgeBasedGraphFactory::Run() { //Loop over all nodes u. Three nested loop look super-linear, but we are dealing with a number linear in the turns only. for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) { //loop over all adjacent edge (u,v) - while(restrictionIterator->fromNode < u && inputRestrictions.end() != restrictionIterator) { + while(inputRestrictions.end() != restrictionIterator && restrictionIterator->fromNode < u) { ++restrictionIterator; } for(_NodeBasedDynamicGraph::EdgeIterator e1 = _nodeBasedGraph->BeginEdges(u); e1 < _nodeBasedGraph->EndEdges(u); ++e1) { @@ -115,7 +115,7 @@ void EdgeBasedGraphFactory::Run() { //if (u,v,w) is a forbidden turn, continue bool isTurnProhibited = false; if( u != w ) { //only add an edge if turn is not a U-turn - if(u == restrictionIterator->fromNode) { + if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) { std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator; do { if( v == secondRestrictionIterator->viaNode && w == secondRestrictionIterator->toNode) {