From e28cce87c7551bffa1f4602ff492348f9a8cba60 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Thu, 10 Dec 2020 05:35:40 -0800 Subject: Ensure that no pointer handles leak during the test (#712) This change makes sure that pointer handles are correctly cleaned up during tests. --- object.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'object.go') diff --git a/object.go b/object.go index 762ad3d..bf0ca0e 100644 --- a/object.go +++ b/object.go @@ -77,14 +77,14 @@ func (o *Object) Type() ObjectType { return ret } -// Owner returns a weak reference to the repository which owns this -// object. This won't keep the underlying repository alive. +// Owner returns a weak reference to the repository which owns this object. +// This won't keep the underlying repository alive, but it should still be +// Freed. func (o *Object) Owner() *Repository { - ret := &Repository{ - ptr: C.git_object_owner(o.ptr), - } + repo := newRepositoryFromC(C.git_object_owner(o.ptr)) runtime.KeepAlive(o) - return ret + repo.weak = true + return repo } func dupObject(obj *Object, kind ObjectType) (*C.git_object, error) { -- cgit v1.2.3