comparison mercurial/cext/bdiff.c @ 39421:ad76032d27da stable

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.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 05 Sep 2018 22:10:41 +0900
parents 93b812d5b818
children 763b45bc4483
comparison
equal deleted inserted replaced
39420:91477b123700 39421:ad76032d27da
254 static int hunk_consumer(int64_t a1, int64_t a2, int64_t b1, int64_t b2, 254 static int hunk_consumer(int64_t a1, int64_t a2, int64_t b1, int64_t b2,
255 void *priv) 255 void *priv)
256 { 256 {
257 PyObject *rl = (PyObject *)priv; 257 PyObject *rl = (PyObject *)priv;
258 PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2); 258 PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2);
259 int r;
259 if (!m) 260 if (!m)
260 return -1; 261 return -1;
261 if (PyList_Append(rl, m) != 0) { 262 r = PyList_Append(rl, m);
262 Py_DECREF(m); 263 Py_DECREF(m);
263 return -1; 264 return r;
264 }
265 return 0;
266 } 265 }
267 266
268 static PyObject *xdiffblocks(PyObject *self, PyObject *args) 267 static PyObject *xdiffblocks(PyObject *self, PyObject *args)
269 { 268 {
270 Py_ssize_t la, lb; 269 Py_ssize_t la, lb;