Skip to content

Commit

Permalink
Fix reference leak in Repository.notes(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavid committed Jun 11, 2021
1 parent 4a0cac7 commit 134ae28
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,26 +1770,26 @@ PyDoc_STRVAR(Repository_notes__doc__, "");
PyObject *
Repository_notes(Repository *self, PyObject *args)
{
NoteIter *iter = NULL;
char *ref = "refs/notes/commits";
int err = GIT_ERROR;

if (!PyArg_ParseTuple(args, "|s", &ref))
return NULL;

iter = PyObject_New(NoteIter, &NoteIterType);
if (iter != NULL) {
iter->repo = self;
iter->ref = ref;
NoteIter *iter = PyObject_New(NoteIter, &NoteIterType);
if (iter == NULL)
return NULL;

err = git_note_iterator_new(&iter->iter, self->repo, iter->ref);
if (err == GIT_OK) {
Py_INCREF(self);
return (PyObject*)iter;
}
Py_INCREF(self);
iter->repo = self;
iter->ref = ref;
iter->iter = NULL;

int err = git_note_iterator_new(&iter->iter, self->repo, iter->ref);
if (err != GIT_OK) {
Py_DECREF(iter);
return Error_set(err);
}

return Error_set(err);
return (PyObject*)iter;
}


Expand Down

0 comments on commit 134ae28

Please sign in to comment.