# HG changeset patch # User Danek Duvall # Date 2014-06-11 22:31:04 # Node ID 8da100383dc32c1f12dcc3ce8dd4ea38c6281158 # Parent 14560418856dbd2b1b5d0bf1b4ae3bceffc4eef0 parsers.c: fix a couple of memory leaks diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -1299,7 +1299,7 @@ static PyObject *find_deepest(indexObjec static const Py_ssize_t capacity = 24; int *depth, *interesting = NULL; int i, j, v, ninteresting; - PyObject *dict = NULL, *keys; + PyObject *dict = NULL, *keys = NULL; long *seen = NULL; int maxrev = -1; long final; @@ -1403,8 +1403,10 @@ static PyObject *find_deepest(indexObjec final |= i; j -= 1; } - if (final == 0) - return PyList_New(0); + if (final == 0) { + keys = PyList_New(0); + goto bail; + } dict = PyDict_New(); if (dict == NULL) @@ -1428,19 +1430,13 @@ static PyObject *find_deepest(indexObjec keys = PyDict_Keys(dict); - free(depth); - free(seen); - free(interesting); - Py_DECREF(dict); - - return keys; bail: free(depth); free(seen); free(interesting); Py_XDECREF(dict); - return NULL; + return keys; } /*