Bug in Player.SetCustomProperties, expectedValues is not being null checked before being used


public void SetCustomProperties(Hashtable propertiesToSet, Hashtable expectedValues = null, WebFlags webFlags = null)
{
            if (propertiesToSet == null)
            {
                return;
            }

            Hashtable customProps = propertiesToSet.StripToStringKeys() as Hashtable;
            Hashtable customPropsToCheck = expectedValues.StripToStringKeys() as Hashtable;

Comments

  • Thanks for the report.
  • Hi @KirkGames,

    Thank you for choosing Photon and for your report!

    I guess you are referring to this exact line:
    Hashtable customPropsToCheck = expectedValues.StripToStringKeys() as Hashtable;
    
    This line won't throw a NullReferenceException since the extension method StripToStringKeys includes the null check itself.
    public static Hashtable StripToStringKeys(this IDictionary original)
            {
                Hashtable target = new Hashtable();
                if (original != null)
                {
                    foreach (object key in original.Keys)
                    {
                        if (key is string)
                        {
                            target[key] = original[key];
                        }
                    }
                }
    
                return target;
            }
  • his eyes open
Sign In or Register to comment.