[PATCH 1 of 7] parsers: fix leak of err when asciilower hits a unicode decode error

Augie Fackler raf at durin42.com
Fri Jan 23 15:53:29 CST 2015


On Jan 23, 2015, at 4:21 PM, Martin von Zweigbergk <martinvonz at google.com> wrote:

> Nice finds!
> 
> On Fri Jan 23 2015 at 1:08:40 PM Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1422044344 18000
> #      Fri Jan 23 15:19:04 2015 -0500
> # Branch stable
> # Node ID 3435cf143b791612214a871337e8549e7d5c26a6
> # Parent  de519517f597abd733961a8c549074eecb6c0ab3
> parsers: fix leak of err when asciilower hits a unicode decode error
> 
> This is one of many errors detected in parsers.c by cpychecker[1]. I
> haven't gone through all of them yet.
> 
> 1: https://gcc-python-plugin.readthedocs.org/en/latest/index.html
> 
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -45,11 +45,11 @@ static char lowertable[128] = {
>         '\x30', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37',
>         '\x38', '\x39', '\x3a', '\x3b', '\x3c', '\x3d', '\x3e', '\x3f',
>         '\x40',
> -               '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', /* A-G */
> +               '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67', /* A-G */
>         '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f', /* H-O */
>         '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77', /* P-W */
>         '\x78', '\x79', '\x7a',                                         /* X-Z */
> -                               '\x5b', '\x5c', '\x5d', '\x5e', '\x5f',
> +                               '\x5b', '\x5c', '\x5d', '\x5e', '\x5f',
> 
> Were these changes intentional? (Replacing spaces by tabs? I'm not sure if it's just Inbox that presents tabs as spaces. Too lazy to check.)

No, that was emacs being jerk and "fixing" it for me. I can do a resend, or just drop this hunk.

>  
>         '\x60', '\x61', '\x62', '\x63', '\x64', '\x65', '\x66', '\x67',
>         '\x68', '\x69', '\x6a', '\x6b', '\x6c', '\x6d', '\x6e', '\x6f',
>         '\x70', '\x71', '\x72', '\x73', '\x74', '\x75', '\x76', '\x77',
> @@ -115,6 +115,7 @@ static PyObject *asciilower(PyObject *se
>                                 "ascii", str, len, i, (i + 1),
>                                 "unexpected code byte");
>                         PyErr_SetObject(PyExc_UnicodeDecodeError, err);
> +                       Py_XDECREF(err);
> 
> Could be Py_DECREF instead? It seems like err should never be NULL.
>  
>                         goto quit;
>                 }
>                 newstr[i] = lowertable[(unsigned char)c];
> _______________________________________________
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150123/09868e38/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150123/09868e38/attachment.pgp>


More information about the Mercurial-devel mailing list