Skip to content

Commit

Permalink
Fix nullable reference exception in CssOriginValue
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Feb 26, 2024
1 parent 0652a66 commit 46635ab
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/AngleSharp.Css/Values/Composites/CssOriginValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace AngleSharp.Css.Values
{
using AngleSharp.Css.Dom;
using System;
using System.Collections.Generic;

/// <summary>
/// Represents a CSS origin definition.
Expand Down Expand Up @@ -73,14 +74,17 @@ public String CssText
/// <returns>True if both are equal, otherwise false.</returns>
public Boolean Equals(CssOriginValue other)
{
return _x.Equals(other._x) && _y.Equals(other._y) && _z.Equals(other._z);
return other is not null
&& EqualityComparer<ICssValue>.Default.Equals(_x, other._x)
&& EqualityComparer<ICssValue>.Default.Equals(_y, other._y)
&& EqualityComparer<ICssValue>.Default.Equals(_z, other._z);
}

ICssValue ICssValue.Compute(ICssComputeContext context)
{
var x = _x.Compute(context);
var y = _y.Compute(context);
var z = _z.Compute(context);
var x = _x?.Compute(context);
var y = _y?.Compute(context);
var z = _z?.Compute(context);

if (x != _x || y != _y || z != _z)
{
Expand Down

0 comments on commit 46635ab

Please sign in to comment.