From 73af642b8f9b0819f67ad12a07bcbe0b373c8aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= Date: Tue, 18 Oct 2011 11:27:32 +0200 Subject: [PATCH] tags: properly dealloc tags There were two memory leaks: we were not closing the git_tag object, and we were not decreasing the refcount on the repo. This finishes fixing issue #20 --- pygit2.c | 2 ++ test/test_tag.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pygit2.c b/pygit2.c index 483b012..6a65f3a 100644 --- a/pygit2.c +++ b/pygit2.c @@ -1658,7 +1658,9 @@ static PyTypeObject BlobType = { static void Tag_dealloc(Tag *self) { + git_tag_close(self->tag); Py_XDECREF(self->target); + Py_XDECREF(self->repo); Py_TYPE(self)->tp_free((PyObject*)self); } diff --git a/test/test_tag.py b/test/test_tag.py index 0c8989d..ad786f0 100644 --- a/test/test_tag.py +++ b/test/test_tag.py @@ -54,7 +54,6 @@ class TagTest(utils.BareRepoTestCase): self.assertEqual('Tagged root commit.\n', tag.message) commit = tag.target - del tag self.assertEqual('Initial test data commit.\n', commit.message) def test_new_tag(self):