Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 14c3841

Browse files
committed
Merge pull request #123 from github/nullref
Fix potential NullReferenceExceptions
2 parents 4df3dfb + 1d93af0 commit 14c3841

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/DesignTimeStyleHelper/App.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ T Create<T>() where T : class
110110
return new Mock<T>().Object;
111111
}
112112

113-
object Create(Type t)
113+
static object Create(Type t)
114114
{
115115
var moq = typeof(Mock<>).MakeGenericType(t);
116116
var ctor = moq.GetConstructor(new Type[] { });
117-
var m = ctor.Invoke(new object[] { }) as Mock;
118-
return m.Object;
117+
var m = ctor?.Invoke(new object[] { }) as Mock;
118+
return m?.Object;
119119
}
120120

121121
public ExportProvider DefaultExportProvider { get; set; }

src/GitHub.Exports/Primitives/HostAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public override bool Equals(object obj)
9898
if (ReferenceEquals(this, obj))
9999
return true;
100100
var other = obj as HostAddress;
101-
return obj != null && WebUri.IsSameHost(other.WebUri) && ApiUri.IsSameHost(other.ApiUri);
101+
return other != null && WebUri.IsSameHost(other.WebUri) && ApiUri.IsSameHost(other.ApiUri);
102102
}
103103
}
104104
}

0 commit comments

Comments
 (0)