Skip to content

Commit 9c43f85

Browse files
committed
Fix memory leak
1 parent 985b147 commit 9c43f85

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,14 +1606,10 @@ internal static extern void git_strarray_free(
16061606
/// the submodule repo and perform the clone step as needed. Lastly, call
16071607
/// 'git_submodule_add_finalize()' to wrap up adding the new submodule and
16081608
/// .gitmodules to the index to be ready to commit.
1609+
///
1610+
/// In our case, go ahead and do the clone first. The setup can be done
1611+
/// with the directory contents already in place.
16091612
/// </summary>
1610-
//[DllImport(libgit2)]
1611-
//internal static extern unsafe int git_submodule_add_setup(
1612-
// out git_submodule* reference,
1613-
// git_repository* repo,
1614-
// [CustomMarshaler(typeof(StrictUtf8Marshaler), typeof(string))] byte* url,
1615-
// [CustomMarshaler(typeof(StrictUtf8Marshaler), typeof(string))] byte* path,
1616-
// int use_gitlink);
16171613
[DllImport(libgit2)]
16181614
private static extern unsafe int git_submodule_add_setup(
16191615
out git_submodule* reference,

LibGit2Sharp/SubmoduleCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public virtual void Add(string url, string path, int useGitLink)
6060
{
6161
SubmoduleHandle handle = Proxy.git_submodule_add_setup(repo.Handle, url, path, useGitLink);
6262
Proxy.git_submodule_add_finalize(handle);
63+
handle.Free();
6364
}
6465

6566
/// <summary>

0 commit comments

Comments
 (0)