Skip to content

Commit 707a03b

Browse files
committed
Fix SIGSEGV on double free for Cred object
This change removes the Go finalizer when passing ownership to libgit2. Fixes: #553 (cherry picked from commit 0843b82)
1 parent 4681adf commit 707a03b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

remote.go

+4
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
248248
ret, cred := callbacks.CredentialsCallback(url, username_from_url, (CredType)(allowed_types))
249249
if cred != nil {
250250
*_cred = cred.ptr
251+
252+
// have transferred ownership to libgit, 'forget' the native pointer
253+
cred.ptr = nil
254+
runtime.SetFinalizer(cred, nil)
251255
}
252256
return int(ret)
253257
}

0 commit comments

Comments
 (0)