We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 91819fb commit 23a6a47Copy full SHA for 23a6a47
1 file changed
src/init.lua
@@ -23,7 +23,8 @@ ffi.cdef [[
23
typedef struct { const char *message; int klass; } git_error;
24
25
const git_error *git_error_last(void);
26
- int git_libgit2_init(void);
+ int git_libgit2_init(void);
27
+ void git_libgit2_shutdown(void);
28
29
int git_repository_open(git_repository **out, const char *path);
30
int git_repository_init(git_repository **out, const char *path, unsigned is_bare);
@@ -278,4 +279,8 @@ function git2.init(path, bare)
278
279
return Repo.new(rp[0])
280
end
281
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
+
286
return git2
0 commit comments