[PATCH 1 of 5 STABLE] base85: fix leak on error return from b85decode()
Martin von Zweigbergk
martinvonz at google.com
Wed Sep 5 11:38:35 EDT 2018
On Wed, Sep 5, 2018 at 8:20 AM Martin von Zweigbergk <martinvonz at google.com>
wrote:
>
>
> On Wed, Sep 5, 2018 at 7:00 AM Yuya Nishihara <yuya at tcha.org> wrote:
>
>> # HG changeset patch
>> # User Yuya Nishihara <yuya at tcha.org>
>> # Date 1536148658 -32400
>> # Wed Sep 05 20:57:38 2018 +0900
>> # Branch stable
>> # Node ID 33c58a7ff5d54660c5c15a007d8297119cf9ab82
>> # Parent e574cae381b66a8543c8183a76768abcb55d98fc
>> base85: fix leak on error return from b85decode()
>>
>> Spotted by ASAN.
>>
>> We don't need to initialize 'out' to NULL, but I decided to do that for
>> clarity.
>>
>
> Looks like that would lead to a "declaration after statement" warning or
> whatever it's called. I might drop it in flight if it does indeed cause
> that.
>
I was wrong, it's still a declaration even if it contains an initialization.
>
>>
>> diff --git a/mercurial/cext/base85.c b/mercurial/cext/base85.c
>> --- a/mercurial/cext/base85.c
>> +++ b/mercurial/cext/base85.c
>> @@ -77,7 +77,7 @@ static PyObject *b85encode(PyObject *sel
>>
>> static PyObject *b85decode(PyObject *self, PyObject *args)
>> {
>> - PyObject *out;
>> + PyObject *out = NULL;
>> const char *text;
>> char *dst;
>> Py_ssize_t len, i, j, olen, cap;
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180905/25afbaff/attachment.html>
More information about the Mercurial-devel
mailing list