xdiff: fix leak in hunk_consumer() stable
authorYuya Nishihara <yuya@tcha.org>
Wed, 05 Sep 2018 22:10:41 +0900
branchstable
changeset 39421 ad76032d27da
parent 39420 91477b123700
child 39422 adacefb0b7ea
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.
mercurial/cext/bdiff.c
--- a/mercurial/cext/bdiff.c	Wed Sep 05 20:57:38 2018 +0900
+++ b/mercurial/cext/bdiff.c	Wed Sep 05 22:10:41 2018 +0900
@@ -256,13 +256,12 @@
 {
 	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)