Jump to content

Action Upgrade can potentially cause crash


Rickzzs
  • Fixed
ACTIONS.UPGRADE.fn = function(act)
    if act.invobject and act.target and
        act.invobject.components.upgrader and
        act.invobject.components.upgrader:CanUpgrade(act.target, act.doer) and
        act.target.components.upgradeable then

        local can_upgrade, reason = act.target.components.upgradeable:CanUpgrade()
        if can_upgrade then
            return act.target.components.upgradeable:Upgrade(act.invobject, act.doer)
        end

        return false, reason
    end
end

Look at how the if statement check the condition.

CanUpgrade uses target.components.upgradeable before it is checked. This may cause a crash if there is no target.components.upgradeable.

You can solve this by swapping the order of the two lines.


Steps to Reproduce

look at actions.lua

  • Like 2



User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...