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

Fixed stmgr unittest segfault issue on macOS #3767

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

nicknezis
Copy link
Contributor

This fixes an issue in which we deleted an item in a loop which invalidated the iterator. An example can be found here: https://stackoverflow.com/a/4636230

Could update to use the returned itr as shown below:

  for (auto itr = common.instanceid_instance_.begin();
       itr != common.instanceid_instance_.end(); ++itr)
      itr = common.instanceid_instance_.erase(itr);

But I instead opted for the map.clear() because the map values are of type shared_ptr.

@nicknezis nicknezis self-assigned this Jan 24, 2022
@nicknezis nicknezis merged commit 638cff1 into master Jan 24, 2022
@nicknezis nicknezis deleted the nicknezis/stmgr-unittest-fix branch January 24, 2022 19:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants