8000 Fix double instantiation of ObjectSafeWrapper · mm201/libgit2sharp@b845bb9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b845bb9

Browse files
yorahnulltoken
authored andcommitted
Fix double instantiation of ObjectSafeWrapper
1 parent d03bcb9 commit b845bb9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

LibGit2Sharp/Core/DisposableEnumerable.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ namespace LibGit2Sharp.Core
66
{
77
internal class DisposableEnumerable<T> : IEnumerable<T>, IDisposable where T : IDisposable
88
{
9-
private readonly IEnumerable<T> enumerable;
9+
private readonly IList<T> enumerable;
1010

11-
public DisposableEnumerable(IEnumerable<T> enumerable)
11+
public DisposableEnumerable(IList<T> enumerable)
1212
{
1313
this.enumerable = enumerable;
1414
}
1515

16+
public int Count
17+
{
18+
get { return enumerable.Count; }
19+
}
20+
1621
public IEnumerator<T> GetEnumerator()
1722
{
1823
return enumerable.GetEnumerator();

LibGit2Sharp/Core/Proxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public static ObjectId git_commit_create(
253253
{
254254
using (ThreadAffinity())
255255
using (var treePtr = new ObjectSafeWrapper(tree.Id, repo))
256-
using (var parentObjectPtrs = new DisposableEnumerable<ObjectSafeWrapper>(parentIds.Select(id => new ObjectSafeWrapper(id, repo))))
256+
using (var parentObjectPtrs = new DisposableEnumerable<ObjectSafeWrapper>(parentIds.Select(id => new ObjectSafeWrapper(id, repo)).ToList()))
257257
using (SignatureSafeHandle authorHandle = author.BuildHandle())
258258
using (SignatureSafeHandle committerHandle = committer.BuildHandle())
259259
{
@@ -262,7 +262,7 @@ public static ObjectId git_commit_create(
262262

263263
IntPtr[] parentsPtrs = parentObjectPtrs.Select(o => o.ObjectPtr.DangerousGetHandle()).ToArray();
264264
int res = NativeMethods.git_commit_create(out commitOid, repo, referenceName, authorHandle,
265-
committerHandle, encoding, prettifiedMessage, treePtr.ObjectPtr, parentObjectPtrs.Count(), parentsPtrs);
265+
committerHandle, encoding, prettifiedMessage, treePtr.ObjectPtr, parentObjectPtrs.Count, parentsPtrs);
266266
Ensure.ZeroResult(res);
267267

268268
return new ObjectId(commitOid);

0 commit comments

Comments
 (0)
0