# HG changeset patch # User Yuya Nishihara # Date 2018-09-05 13:10:41 # Node ID ad76032d27da158dc0a067a3a1199104261b7476 # Parent 91477b1237008222c56f20333fa59a8ffd205883 xdiff: fix leak in hunk_consumer() Spotted by ASAN. Since PyList_Append() does not "steal" a reference, Py_DECREF() is always required. Perhaps, this is the largest leak in this series. diff --git a/mercurial/cext/bdiff.c b/mercurial/cext/bdiff.c --- a/mercurial/cext/bdiff.c +++ b/mercurial/cext/bdiff.c @@ -256,13 +256,12 @@ static int hunk_consumer(int64_t a1, int { PyObject *rl = (PyObject *)priv; PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2); + int r; if (!m) return -1; - if (PyList_Append(rl, m) != 0) { - Py_DECREF(m); - return -1; - } - return 0; + r = PyList_Append(rl, m); + Py_DECREF(m); + return r; } static PyObject *xdiffblocks(PyObject *self, PyObject *args)