File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ ffi.cdef [[
2323 typedef struct { const char * message ; int klass ; } git_error;
2424
2525 const git_error *git_error_last (void );
26- int git_libgit2_init (void );
26+ int git_libgit2_init (void );
27+ void git_libgit2_shutdown (void );
2728
2829 int git_repository_open (git_repository ** out , const char * path );
2930 int git_repository_init (git_repository ** out , const char * path , unsigned is_bare );
@@ -278,4 +279,8 @@ function git2.init(path, bare)
278279 return Repo .new (rp [0 ])
279280end
280281
282+ -- Call git_libgit2_shutdown when the module is GC'd to avoid a segfault on DLL unload.
283+ -- The closure keeps `lib` alive until after shutdown runs.
284+ git2 ._gc = ffi .gc (ffi .new (" char[1]" ), function () lib .git_libgit2_shutdown () end )
285+
281286return git2
You can’t perform that action at this time.
0 commit comments