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

async_hooks: avoid decrementing iterator after erase #42749

Merged

Commits on Apr 15, 2022

  1. async_hooks: avoid decrementing iterator after erase

    decrementing an iterator returned by `std::vector::erase` may have
    undefined behaviour and should not be used. Decrementing `end()`
    on an empty container is undefined and `.erase()` could leave
    the container empty.
    
    Instead, by calling `vec.erase(it--)` we decrement the valid iterator
    before the erase operation but after being passed to the erase method.
    
    In case of `AsyncHooks::RemoveContext` perform the cleanup of empty
    contexts upfront using `std::remove_if` because the iteration gets
    interrupted as soon as the context to be removed has been found.
    dygabo committed Apr 15, 2022
    Configuration menu
    Copy the full SHA
    8f3ce94 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    84dd569 View commit details
    Browse the repository at this point in the history