[PATCH 2 of 5 STABLE] xdiff: fix leak in hunk_consumer()
Yuya Nishihara
yuya at tcha.org
Wed Sep 5 13:58:24 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1536153041 -32400
# Wed Sep 05 22:10:41 2018 +0900
# Branch stable
# Node ID c1556580015504061ab7d1e48e81f5514adc60ac
# Parent 33c58a7ff5d54660c5c15a007d8297119cf9ab82
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)
More information about the Mercurial-devel
mailing list