Prevent plugins from freeing active private forward handle #1043
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.
PR is a fix for #1041.
Because the handle is only read once during
sm_CallStartForward, and to avoid keeping an owned plugin's handle (where the plugin can delete it prior to finishing the call) and interfering with the behavior ofsm_CallFinish(by changing the order ofResetCall()andpFunction->Execute()), I opted to clone it twice, which doesn't seem ideal.I've marked this as a draft to get opinions. The unimplemented alternatives I can think of would be to either:
Handle_tvalue and ensure its validity atsm_CallFinish(which should be acceptable in theory; if the handle was freed prior to the call being finishedI'd imagine it would also cause issuesit causes a segfault anyways)ResetCall()when SourceMod is finishing the call (I didn't want to modifyResetCallwith a bool param if I didn't have to)