Skip to content

Commit 0843b82

Browse files
authored
Fix SIGSEGV on double free for Cred object
This change removes the Go finalizer when passing ownership to libgit2. Fixes: libgit2#553
2 parents 3a21026 + 89dc80b commit 0843b82

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

remote.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
255255
}
256256
if cred != nil {
257257
*_cred = cred.ptr
258+
259+
// have transferred ownership to libgit, 'forget' the native pointer
260+
cred.ptr = nil
261+
runtime.SetFinalizer(cred, nil)
258262
}
259263
return 0
260264
}

0 commit comments

Comments
 (0)