Guard stale FAdmin action targets - #3305
Conversation
|
Thanks for the contribution! I see that you've made quite some PRs to add defensive programming. Just for my understanding, what is the context? Are these errors you've witnessed or e.g. the results of some scan? |
|
Thanks! The context is a manual/static review pass, not a production incident report. I was looking specifically for low-risk runtime error paths where callbacks or UI prompts keep player/entity references across a delay, or where malformed command input reaches GLua calls before validation. So I have not personally seen these exact errors on a live server. I split the changes into small PRs because some of them are more obviously correctness fixes than others, and I am happy to close or narrow anything that feels too defensive for DarkRP core. For this PR specifically, the intent is just to make FAdmin action callbacks no-op when their target/source disappeared before the delayed code runs, and to reject malformed TPToPos input before constructing vectors. |
|
Thanks for elaborating! Due to time constraints it might take a bit before reviewing the PRs. In the meantime I'll enable the workflows. |
|
No problem at all, thanks for enabling the workflows! Take your time. I will keep an eye on the checks and adjust if anything fails. |
| if PHYSGUN then timer.Simple(0.5, function() target:Give("weapon_physgun") target:SelectWeapon("weapon_physgun") end) end | ||
| if PHYSGUN then | ||
| timer.Simple(0.5, function() | ||
| if not IsValid(target) then return end |
There was a problem hiding this comment.
Nice finds with these timers. Easy to forget to check validity 👍
Summary
Why
Several admin actions keep player or entity references across timers or UI prompts. If the player disconnects, the target disappears, or the command is malformed before the callback runs, the old reference could be used directly and throw a Lua error.
Checks