Skip to content

Conversation

Architector4
Copy link

In RunScriptFunctionObject, script timing is calculated before/after running the script, then written into PerformanceMan::m_ScriptTimings table based on the path to the script. This introduces a use-after-free error and likely crashing if the script in question deallocates the function object, like Combat Shield's "Detach" pie menu option deleting itself: #219

My fix here is to get the table entry before running the script, store a pointer to it in a variable, and then access it directly after running the script. This also removes the double lookup into the unordered_map.

In my testing, this fixes the issue entirely. I'm not knowledgeable on this codebase or on C++isms, I don't know what's the policy of the project on raw pointers, so if this doesn't fit, please feel free to disregard this and implement an equivalent kind of a solution in proper language etiquette instead lol

Fixes #219

HeliumAnt
HeliumAnt previously approved these changes Oct 2, 2025
Copy link
Contributor

@HeliumAnt HeliumAnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when detaching weapon from Combat Shield

2 participants