summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-03-26 17:50:12 -0700
committerGitHub <[email protected]>2020-03-26 17:50:12 -0700
commit0843b826d219b16d55d3bb7fffbb5fb3fbbf82f8 (patch)
tree9330757c7ce09c8023616a91c8099ddb4c15aebb
parent3a2102638d64cd76e50f51577e8bb2b8f9c7035f (diff)
parent89dc80bbea1a418182d31fcdb34b0c2ebeaf7c16 (diff)
Fix SIGSEGV on double free for Cred object
This change removes the Go finalizer when passing ownership to libgit2. Fixes: #553
-rw-r--r--remote.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/remote.go b/remote.go
index c966aab..9d65d10 100644
--- a/remote.go
+++ b/remote.go
@@ -255,6 +255,10 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
}
if cred != nil {
*_cred = cred.ptr
+
+ // have transferred ownership to libgit, 'forget' the native pointer
+ cred.ptr = nil
+ runtime.SetFinalizer(cred, nil)
}
return 0
}