Skip to content

Commit

Permalink
Merge #127
Browse files Browse the repository at this point in the history
127: Fix a stack overflow error in DrainIterator r=adamreichold,rmanoka a=nickguletskii

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `rstar/CHANGELOG.md` if knowledge of this change could be valuable to users.
---

Fixes a stack overflow error when using `RTree::drain_with_selection_function` or any other method that uses `DrainIterator`.

Co-authored-by: Nick Guletskii <[email protected]>
  • Loading branch information
bors[bot] and nickguletskii authored Jun 19, 2023
2 parents bfea7bf + f4d43ae commit cb6fe73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rstar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

## Changed
- Fixed a stack overflow error in `DrainIterator::next`

# 0.11.0

## Added
Expand Down
4 changes: 2 additions & 2 deletions rstar/src/algorithm/removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
loop {
'attempt_loop: loop {
// Get reference to top node or return None.
let (node, idx, remove_count) = match self.node_stack.last_mut() {
Some(node) => (&mut node.0, &mut node.1, &mut node.2),
Expand All @@ -149,7 +149,7 @@ where
RTreeNode::Parent(node) => node,
};
self.node_stack.push((child, 0, 0));
return self.next();
continue 'attempt_loop;
}
RTreeNode::Leaf(ref leaf) => {
if self.removal_function.should_unpack_leaf(leaf) {
Expand Down

0 comments on commit cb6fe73

Please sign in to comment.