-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Labels
Description
The lines valuestr ? valuestr : Py_None,
and Py_DECREF(valuestr);
in the block
Lines 259 to 275 in 52077e8
valuestr = LDAPberval_to_object(retdata); | |
ber_bvfree( retdata ); | |
pyoid = PyUnicode_FromString(retoid); | |
ldap_memfree( retoid ); | |
if (pyoid == NULL) { | |
Py_DECREF(result); | |
ldap_msgfree( m ); | |
return NULL; | |
} | |
valtuple = Py_BuildValue("(OOO)", pyoid, | |
valuestr ? valuestr : Py_None, | |
pyctrls); | |
Py_DECREF(pyoid); | |
Py_DECREF(valuestr); | |
Py_XDECREF(pyctrls); | |
PyList_Append(result, valtuple); | |
Py_DECREF(valtuple); |
LDAPberval_to_object()
can return NULL in case PyBytes_FromStringAndSize()
fails. Later the value is dereferenced in Py_DECREF(valuestr);
.
The function must verify valuestr
. Also Py_BuildValue()
can be simplified by using N
instead of O
. https://docs.python.org/3/c-api/arg.html?highlight=py_buildvalue#c.Py_BuildValue