Skip to content

Commit dbcd2be

Browse files
committed
TreeEntry: fix repo refcount
1 parent 2993675 commit dbcd2be

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/tree.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern PyTypeObject TreeIterType;
4242
extern PyTypeObject IndexType;
4343

4444
#if PY_MAJOR_VERSION >= 3
45-
#define Py_TPFLAGS_CHECKTYPES 0
45+
#define Py_TPFLAGS_CHECKTYPES 0 // removed in Py3, needed in Py2
4646
#endif
4747

4848

@@ -455,8 +455,12 @@ wrap_tree_entry(const git_tree_entry *entry, Repository *repo)
455455
if (py_entry)
456456
{
457457
py_entry->entry = entry;
458-
py_entry->repo = repo;
459-
}
458+
if (repo)
459+
{
460+
py_entry->repo = repo;
461+
Py_INCREF(repo);
462+
}
463+
}
460464

461465
return py_entry;
462466
}

0 commit comments

Comments
 (0)