comparison mercurial/parsers.c @ 26048:0be2f81aadc3

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.
author Augie Fackler <augie@google.com>
date Tue, 18 Aug 2015 17:15:04 -0400
parents b3ad349d0e50
children b1634b7804c7
comparison
equal deleted inserted replaced
26047:d9d3d49c4cf7 26048:0be2f81aadc3
2156 * Given a (possibly overlapping) set of revs, return the greatest 2156 * Given a (possibly overlapping) set of revs, return the greatest
2157 * common ancestors: those with the longest path to the root. 2157 * common ancestors: those with the longest path to the root.
2158 */ 2158 */
2159 static PyObject *index_ancestors(indexObject *self, PyObject *args) 2159 static PyObject *index_ancestors(indexObject *self, PyObject *args)
2160 { 2160 {
2161 PyObject *ret;
2161 PyObject *gca = index_commonancestorsheads(self, args); 2162 PyObject *gca = index_commonancestorsheads(self, args);
2162 if (gca == NULL) 2163 if (gca == NULL)
2163 return NULL; 2164 return NULL;
2164 2165
2165 if (PyList_GET_SIZE(gca) <= 1) { 2166 if (PyList_GET_SIZE(gca) <= 1) {
2166 Py_INCREF(gca);
2167 return gca; 2167 return gca;
2168 } 2168 }
2169 2169
2170 return find_deepest(self, gca); 2170 ret = find_deepest(self, gca);
2171 Py_DECREF(gca);
2172 return ret;
2171 } 2173 }
2172 2174
2173 /* 2175 /*
2174 * Invalidate any trie entries introduced by added revs. 2176 * Invalidate any trie entries introduced by added revs.
2175 */ 2177 */