Skip to content

Commit

Permalink
avoid infinite loop when switching between two polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Sep 8, 2024
1 parent 471b3a3 commit a0b54ec
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ impl<'m> SearchInstance<'m> {
#[cfg_attr(feature = "tracing", instrument(skip_all))]
#[inline(always)]
pub(crate) fn successors(&mut self, mut node: SearchNode) {
let mut visited = HashSet::new();
loop {
#[cfg(feature = "stats")]
{
Expand Down Expand Up @@ -849,6 +850,10 @@ impl<'m> SearchInstance<'m> {
);
}
node = self.node_buffer.drain(..).next().unwrap();
if !visited.insert(node.polygon_to) {
// infinite loop, exit now
break;
}
#[cfg(debug_assertions)]
{
self.fail_fast -= 1;
Expand Down

0 comments on commit a0b54ec

Please sign in to comment.