Skip to content

Conversation

dl3sdo
Copy link
Member

@dl3sdo dl3sdo commented Oct 17, 2025

If the last but one map part was removed, setCurrentPartIndex() did an out-of-bounds read access to the parts vector, due to switching to the last map part before removing the last but one part.

Closes GH-2427 (Removing last but one map part causes out-of-bounds access).

If the last but one map part was removed, setCurrentPartIndex() did an
out-of-bounds read access to the parts vector, due to switching to the
last map part before removing the last but one part.

Closes OpenOrienteeringGH-2427 (Removing last but one map part causes out-of-bounds access).
// First switch to another part when removing the current part
setCurrentPartIndex((index == parts.size() - 1) ? (parts.size() - 2) : (index + 1));
// First switch to another part when removing the current part, this will also clear any object selection
setCurrentPartIndex((index == parts.size() - 1) ? (index - 1) : (index + 1));
Copy link
Member Author

Choose a reason for hiding this comment

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

Although index - 1 is equivalent to parts.size() - 2 I prefer it due to readability.

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.

Removing last but one map part causes out-of-bounds access

1 participant