Fixed: Memleak in diff_get_patch_byindex()

There was a memleak because of a missing Py_DECREF. Thanks to @delanne
This commit is contained in:
Nico von Geyso
2013-05-21 13:46:58 +02:00
parent bdff1c3145
commit 7bccfc8d26

View File

@@ -69,6 +69,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
int err; int err;
Hunk *py_hunk = NULL; Hunk *py_hunk = NULL;
Patch *py_patch = NULL; Patch *py_patch = NULL;
PyObject *py_line_origin=NULL, *py_line=NULL;
err = git_diff_get_patch(&patch, &delta, list, idx); err = git_diff_get_patch(&patch, &delta, list, idx);
if (err < 0) if (err < 0)
@@ -108,12 +109,16 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx)
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
py_line_origin = to_unicode_n(&line_origin, 1, NULL, NULL);
py_line = to_unicode_n(line, line_len, NULL, NULL);
PyList_SetItem(py_hunk->lines, j, PyList_SetItem(py_hunk->lines, j,
Py_BuildValue("OO", Py_BuildValue("OO",
to_unicode_n(&line_origin, 1, NULL, NULL), py_line_origin,
to_unicode_n(line, line_len, NULL, NULL) py_line
) )
); );
Py_DECREF(py_line_origin);
Py_DECREF(py_line);
} }
PyList_SetItem((PyObject*) py_patch->hunks, i, PyList_SetItem((PyObject*) py_patch->hunks, i,