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 #468 by removing use of pointers after an invalidation-causing action (CopyEntity).
I briefly reviewed the other code in this massive switch, and the rest (besides helix and revolve) appears to be safe: there are a few other places where the address of a list element is taken, but it's either done in the tightest loop and not used after the invalidation, and/or something like
hEntity he = e->h; e = NULL;
is done, where thenSK.GetEntity(he)
is used after in place ofe
. This seems sufficient, if a bit overkill: it's putting in a log(n) lookup by handle where there's already a good-enough index available (good enough that it's being used to control iteration, anyway.)The last commit here is a matter of style preference: can't use an invalidated pointer if you don't take one in the first place. :) Take or leave, no worries.
The middle commit highlights some things I got confused about when reading the code, as well as adds the comments that got missed due to the feature being in-flight when I added them.