Fix crash due to access after delete#3449
Merged
zimmy87 merged 2 commits intomicrosoft:masterfrom Mar 8, 2021
Merged
Conversation
9445b67 to
424190e
Compare
Contributor
|
Tested on both Windows and Ubuntu. Works perfectly and makes complete sense. |
Contributor
|
Tested this locally on windows and ubuntu and it works for me as well, so I'm going ahead and merging this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #3448
Fixes: #3452
About
This PR fixes a crash due to access after
erasein the map. #3402 added a method that is only supposed to be called once, and after that removes itself. However, the range-based for loop is not suitable for this and causes a crash after the method returns due to the iterator now essentially being invalid. Also, see https://stackoverflow.com/questions/8234779/how-to-remove-from-a-map-while-iterating-it/8234813The second commit adds some cleanup, it isn't actually required but makes things clearer. Can be easily dropped if not preferred
How Has This Been Tested?
Currently only tested with the default multirotor. Also tested by starting and stopping the play and using debug statements to make sure that things are working correctly and no extra items are added to the array
Screenshots (if appropriate):