[python-ldap] [PATCH] Fix check for an empty error message

Bradley Baetz bbaetz at google.com
Sun Jan 8 19:12:47 EST 2017


On Sat, 7 Jan 2017 at 02:11 Michael Ströder <michael at stroeder.com> wrote:

> Bradley Baetz via python-ldap wrote:
> > When trying to get the server's error message, check if the string is
> empty
> > rather than checking the pointer against '\0'. (This is already
> NULL-checked
> > in the previous line)
>
> Thanks for your fix.
>
> Your patch got badly formatted in the HTML mail.
> But I've committed this to CVS HEAD (see below).
>
> Could you please elaborate a bit on how this affected your python-ldap
> usage.
> Such a note in file CHANGES might be helpful for others.
>

This was noticed via some compiler static analysis/warnings for common
typos/errors, rather than a specific bug.

Bradley


>
> Ciao, Michael.
>
> P.S.: Please subscribe to the low-traffic python-ldap mailing list. So I
> don't
> have to approve all your postings and you'll get all responses.
>
> Index: Modules/errors.c
> ===================================================================
> RCS file: /cvsroot/python-ldap/python-ldap/Modules/errors.c,v
> retrieving revision 1.25
> diff -u -r1.25 errors.c
> --- Modules/errors.c    23 Jun 2015 09:45:09 -0000      1.25
> +++ Modules/errors.c    6 Jan 2017 15:00:24 -0000
> @@ -98,7 +98,7 @@
>          Py_XDECREF(str);
>      } else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0
>        && error != NULL) {
> -        if (error != '\0') {
> +        if (*error != '\0') {
>        str = PyString_FromString(error);
>        if (str)
>            PyDict_SetItemString( info, "info", str );
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170109/5c00e758/attachment.html>


More information about the python-ldap mailing list