Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsenodes fix: check if index is out-of-bound first #2984

Merged
merged 3 commits into from
Apr 7, 2021

Conversation

merkispavel
Copy link
Contributor

@merkispavel merkispavel commented Apr 7, 2021

Issue

if the code above results in curren_way_node_index_ == npos then vector out-of-range error happens

if (osmid > (*(*way_nodes_)[current_way_node_index_]).node.osmid_) {
      current_way_node_index_ =
          way_nodes_->find_first_of(OSMWayNode{{osmid}},
                                    [](const OSMWayNode& a, const OSMWayNode& b) {
                                      return a.node.osmid_ <= b.node.osmid_;
                                    },
                                    current_way_node_index_);
    }

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Update the docs with any new request parameters or changes to behavior described
  • Update the changelog

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

Comment on lines -858 to -859
if (osmid < (*(*way_nodes_)[current_way_node_index_]).node.osmid_ ||
current_way_node_index_ >= way_nodes_->size()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, good catch, sorry about that!

kevinkreiser
kevinkreiser previously approved these changes Apr 7, 2021
@gknisely gknisely self-requested a review April 7, 2021 14:29
gknisely
gknisely previously approved these changes Apr 7, 2021
@merkispavel merkispavel dismissed stale reviews from gknisely and kevinkreiser via fe194d8 April 7, 2021 14:31
@merkispavel merkispavel merged commit a9c1646 into master Apr 7, 2021
@merkispavel merkispavel deleted the bugfix-parsenodes branch April 7, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants