Skip to content

Commit 8531e72

Browse files
committed
Add null checks to GitObject and ObjectId
1 parent b7d207f commit 8531e72

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/GitVersion.LibGit2Sharp/Git/GitObject.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ internal class GitObject : IGitObject
99

1010
internal GitObject(LibGit2Sharp.GitObject innerGitObject)
1111
{
12+
if (innerGitObject == null)
13+
throw new ArgumentNullException(nameof(innerGitObject));
14+
1215
Id = new ObjectId(innerGitObject.Id);
1316
Sha = innerGitObject.Sha;
1417
}

src/GitVersion.LibGit2Sharp/Git/ObjectId.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ internal sealed class ObjectId : IObjectId
88
private static readonly LambdaKeyComparer<IObjectId, string> comparerHelper = new(x => x.Sha);
99

1010
private readonly LibGit2Sharp.ObjectId innerObjectId;
11-
internal ObjectId(LibGit2Sharp.ObjectId objectId) => this.innerObjectId = objectId;
11+
12+
internal ObjectId(LibGit2Sharp.ObjectId objectId) =>
13+
this.innerObjectId = objectId ?? throw new ArgumentNullException(nameof(objectId));
1214

1315
public ObjectId(string sha) : this(new LibGit2Sharp.ObjectId(sha))
1416
{

0 commit comments

Comments
 (0)