Fix SIGSEGV on double free for Cred object

This change removes the Go finalizer when passing ownership to libgit2.

Fixes: #553
This commit is contained in:
lhchavez 2020-03-26 17:50:12 -07:00 committed by GitHub
commit 0843b826d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -255,6 +255,10 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
} }
if cred != nil { if cred != nil {
*_cred = cred.ptr *_cred = cred.ptr
// have transferred ownership to libgit, 'forget' the native pointer
cred.ptr = nil
runtime.SetFinalizer(cred, nil)
} }
return 0 return 0
} }