Skip to content

Commit 2f7a40a

Browse files
committed
Guard against marshaling invalid handle as ObjectId
1 parent 746e147 commit 2f7a40a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

LibGit2Sharp/Core/Handles/OidSafeHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal class OidSafeHandle : NotOwnedSafeHandleBase
66
{
77
private GitOid? MarshalAsGitOid()
88
{
9-
return (GitOid?)Marshal.PtrToStructure(handle, typeof(GitOid));
9+
return IsInvalid ? null : (GitOid?)Marshal.PtrToStructure(handle, typeof(GitOid));
1010
}
1111

1212
public ObjectId MarshalAsObjectId()

0 commit comments

Comments
 (0)