Skip to content

Commit 102cc32

Browse files
authored
Merge pull request #162 from meziantou/nre-CssOriginValue
Fix nullable reference exception in CssOriginValue
2 parents c1c83ee + e68db8f commit 102cc32

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/AngleSharp.Css/Values/Composites/CssOriginValue.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace AngleSharp.Css.Values
22
{
33
using AngleSharp.Css.Dom;
44
using System;
5+
using System.Collections.Generic;
56

67
/// <summary>
78
/// Represents a CSS origin definition.
@@ -73,14 +74,20 @@ public String CssText
7374
/// <returns>True if both are equal, otherwise false.</returns>
7475
public Boolean Equals(CssOriginValue other)
7576
{
76-
return _x.Equals(other._x) && _y.Equals(other._y) && _z.Equals(other._z);
77+
if (other is not null)
78+
{
79+
var comparer = EqualityComparer<ICssValue>.Default;
80+
return comparer.Equals(_x, other._x) && comparer.Equals(_y, other._y) && comparer.Equals(_z, other._z);
81+
}
82+
83+
return false;
7784
}
7885

7986
ICssValue ICssValue.Compute(ICssComputeContext context)
8087
{
81-
var x = _x.Compute(context);
82-
var y = _y.Compute(context);
83-
var z = _z.Compute(context);
88+
var x = _x?.Compute(context);
89+
var y = _y?.Compute(context);
90+
var z = _z?.Compute(context);
8491

8592
if (x != _x || y != _y || z != _z)
8693
{

0 commit comments

Comments
 (0)