# HG changeset patch # User Augie Fackler # Date 1439932504 14400 # Node ID 0be2f81aadc3d457643e2e636f9e465a0cbb00e5 # Parent d9d3d49c4cf77049d12920980e91bf8e4a4ecda2 parsers: fix two leaks in index_ancestors Both happy paths through this function leaked the returned list: 1) If the list was of size 0 or 1, it was retained an extra time and then returned. 2) If the list was passed to find_deepest, it was never released before exiting this function. Both paths spotted by cpychecker. diff -r d9d3d49c4cf7 -r 0be2f81aadc3 mercurial/parsers.c --- a/mercurial/parsers.c Tue Aug 18 18:38:56 2015 -0500 +++ b/mercurial/parsers.c Tue Aug 18 17:15:04 2015 -0400 @@ -2158,16 +2158,18 @@ */ static PyObject *index_ancestors(indexObject *self, PyObject *args) { + PyObject *ret; PyObject *gca = index_commonancestorsheads(self, args); if (gca == NULL) return NULL; if (PyList_GET_SIZE(gca) <= 1) { - Py_INCREF(gca); return gca; } - return find_deepest(self, gca); + ret = find_deepest(self, gca); + Py_DECREF(gca); + return ret; } /*