Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Fix access to invalid iterator (w/ C++11 feature) #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lostcoaster
Copy link

Erasing the element invalidates the iterator, which may cause segmentation fault at "++it".
The workaround here is C++ 11 only. In C++ 98 erase(iterator) returns nothing so it will not work.

Solution in C++98 might be keeping the invalid nodeId in an array and removing them after the loop body.

Erasing the element invalidates the iterator, which may cause segmentation fault at "++it".
The workaround here is C++ 11 only. In C++ 98 erase(iterator) returns nothing so it will not work.
Better workaround might be keeping the invalid nodeId in an array and remove them after the loop body.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant