Skip to content

Commit 6948a13

Browse files
committed
fixup! Add support for flags in ldap.dn2str()
1 parent b6a2a5e commit 6948a13

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Modules/functions.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
169169
struct berval str;
170170
LDAPDN dn = NULL;
171171
LDAPRDN rdn = NULL;
172+
LDAPAVA *ava = NULL;
172173
int flags = 0;
173-
PyObject *result = NULL, *tmp = NULL, *dn_list = NULL;
174+
175+
PyObject *result = NULL, *tmp, *dn_list;
176+
PyObject *iter, *inext, *iiter, *next;
177+
PyObject *name, *value, *encoding;
178+
179+
Py_ssize_t nrdns, navas;
174180
int res, i, j;
175181
char *type_error_message = "expected List[List[Tuple[str, str, int]]]";
176182

@@ -185,13 +191,13 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
185191
Py_XDECREF(args);
186192
Py_INCREF(dn_list);
187193

188-
PyObject *iter = PyObject_GetIter(dn_list);
194+
*iter = PyObject_GetIter(dn_list);
189195
if (!iter) {
190196
PyErr_SetString(PyExc_TypeError, type_error_message);
191197
goto failed;
192198
}
193199

194-
Py_ssize_t nrdns = PyObject_Length(dn_list);
200+
nrdns = PyObject_Length(dn_list);
195201
if (nrdns == -1) {
196202
// can't happen
197203
goto failed;
@@ -200,7 +206,7 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
200206

201207
i = 0;
202208
while (1) {
203-
PyObject *inext = PyIter_Next(iter);
209+
*inext = PyIter_Next(iter);
204210
if (!inext) {
205211
break;
206212
}
@@ -215,14 +221,14 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
215221
goto failed;
216222
}
217223

218-
PyObject *iiter = PyObject_GetIter(inext);
224+
*iiter = PyObject_GetIter(inext);
219225

220-
Py_ssize_t navas = PyObject_Length(inext);
226+
navas = PyObject_Length(inext);
221227
rdn = malloc(sizeof(LDAPRDN) * (navas + 1));
222228

223229
j = 0;
224230
while (1) {
225-
PyObject *next = PyIter_Next(iiter);
231+
*next = PyIter_Next(iiter);
226232
if (!next) {
227233
break;
228234
}
@@ -238,8 +244,6 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
238244
goto failed;
239245
}
240246

241-
PyObject *name, *value, *encoding;
242-
243247
name = PyTuple_GetItem(next, 0);
244248
value = PyTuple_GetItem(next, 1);
245249
encoding = PyTuple_GetItem(next, 2);
@@ -255,7 +259,7 @@ l_ldap_dn2str(PyObject *unused, PyObject *args)
255259
goto failed;
256260
}
257261

258-
LDAPAVA *ava = malloc(sizeof(LDAPAVA));
262+
*ava = malloc(sizeof(LDAPAVA));
259263

260264
ava->la_attr.bv_val = (char *) PyUnicode_AsUTF8AndSize(name, (long int*) &ava->la_attr.bv_len);
261265
ava->la_value.bv_val = (char *) PyUnicode_AsUTF8AndSize(value, (long int*) &ava->la_value.bv_len);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy