Unity-Technologies / multiplayer-community-contributions

Community contributions to Unity Multiplayer Networking products and services.
MIT License
421 stars 161 forks source link

Possible System.NullReferenceException in LagCompensationManager #204

Open Lunatix89 opened 1 year ago

Lunatix89 commented 1 year ago

I just stumbled across this while taking a look at the LagCompensationManager - there is a possible System.NullReferenceException in Update:47 which will be caused when networkManager is null.

The issue with this line is, that the && operator has precedence over || so if networkManager is null, it will check the second condition, networkManager.IsClient.


// wrong
networkManger != null && networkManger.IsServer || networkManger.IsClient

// correct
networkManger != null && (networkManger.IsServer || networkManger.IsClient)