Skip to content

Commit

Permalink
Merge pull request #162 from meziantou/nre-CssOriginValue
Browse files Browse the repository at this point in the history
Fix nullable reference exception in CssOriginValue
  • Loading branch information
FlorianRappl authored Feb 26, 2024
2 parents c1c83ee + e68db8f commit 102cc32
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 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,20 @@ 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);
if (other is not null)
{
var comparer = EqualityComparer<ICssValue>.Default;
return comparer.Equals(_x, other._x) && comparer.Equals(_y, other._y) && comparer.Equals(_z, other._z);
}

return false;
}

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 102cc32

Please sign in to comment.