Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix loop: iterator is invalid after insertion.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 11 Jun 2021 09:33:14 +0000 (11:33 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 11 Jun 2021 09:33:14 +0000 (11:33 +0200)
src/kernel/routing/DijkstraZone.cpp

index bccbca7..bae021f 100644 (file)
@@ -193,12 +193,11 @@ void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Rou
       const NetPoint* gw_dst_net_elm      = nullptr;
       const NetPoint* prev_gw_src_net_elm = nullptr;
       get_global_route(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
       const NetPoint* gw_dst_net_elm      = nullptr;
       const NetPoint* prev_gw_src_net_elm = nullptr;
       get_global_route(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
-      auto pos = route->link_list_.begin();
-      for (auto const& link : e_route_as_to_as) {
-        route->link_list_.insert(pos, link);
+      for (auto pos = e_route_as_to_as.rbegin(); pos != e_route_as_to_as.rend(); pos++) {
+        resource::LinkImpl* link = *pos;
+        route->link_list_.insert(route->link_list_.begin(), link);
         if (lat)
           *lat += link->get_latency();
         if (lat)
           *lat += link->get_latency();
-        pos++;
       }
     }
 
       }
     }