[PATCH stable v2] parsers.c: fix a couple of memory leaks
Siddharth Agarwal
sid at less-broken.com
Fri Jul 4 15:24:18 CDT 2014
On 07/03/2014 09:25 PM, Kevin Bullock wrote:
> On Jun 12, 2014, at 6:08 PM, danek.duvall at oracle.com wrote:
>
>> # HG changeset patch
>> # User Danek Duvall <danek.duvall at oracle.com>
>> # Date 1402525864 25200
>> # Wed Jun 11 15:31:04 2014 -0700
>> # Branch stable
>> # Node ID ed93ca72e5f22b29624394a484668c153020882a
>> # Parent b35f8c487e396487e89f98e92da57ac5eb9833af
>> parsers.c: fix a couple of memory leaks
> Appears to have been queued without response as 8da100383dc3. (Hi patchbot!)
My fault -- I didn't hit reply all.
>
> pacem in terris / мир / शान्ति / سَلاَم / 平和
> Kevin R. Bullock
>
>> 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;
>> }
>>
>> /*
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list