Skip to content

Commit

Permalink
Real fix for attrlist=None regression introduced in 2.4.23 by ref cou…
Browse files Browse the repository at this point in the history
…nt patch
  • Loading branch information
stroeder committed Jan 18, 2016
1 parent 6bc4977 commit ad35a27
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions Modules/LDAPObject.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* See http://www.python-ldap.org/ for details.
* $Id: LDAPObject.c,v 1.92 2016/01/16 19:08:34 stroeder Exp $ */
* $Id: LDAPObject.c,v 1.93 2016/01/18 12:33:07 stroeder Exp $ */

#include "common.h"
#include "patchlevel.h"
Expand Down Expand Up @@ -270,32 +270,31 @@ attrs_from_List( PyObject *attrlist, char***attrsp, PyObject** seq) {
PyErr_SetObject( PyExc_TypeError, Py_BuildValue("sO",
"expected *list* of strings, not a string", attrlist ));
goto error;
}

*seq = PySequence_Fast(attrlist, "expected list of strings or None");

if (*seq == NULL)
goto error;
len = PySequence_Length(attrlist);

attrs = PyMem_NEW(char *, len + 1);
if (attrs == NULL)
goto nomem;


for (i = 0; i < len; i++) {
attrs[i] = NULL;
item = PySequence_Fast_GET_ITEM(*seq, i);
if (item == NULL)
goto error;
if (!PyString_Check(item)) {
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("sO",
"expected string in list", item));
} else {
*seq = PySequence_Fast(attrlist, "expected list of strings or None");
if (*seq == NULL)
goto error;

len = PySequence_Length(attrlist);

attrs = PyMem_NEW(char *, len + 1);
if (attrs == NULL)
goto nomem;

for (i = 0; i < len; i++) {
attrs[i] = NULL;
item = PySequence_Fast_GET_ITEM(*seq, i);
if (item == NULL)
goto error;
if (!PyString_Check(item)) {
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("sO",
"expected string in list", item));
goto error;
}
attrs[i] = PyString_AsString(item);
}
attrs[i] = PyString_AsString(item);
attrs[len] = NULL;
}
attrs[len] = NULL;

*attrsp = attrs;
return 1;
Expand Down

0 comments on commit ad35a27

Please sign in to comment.