From 7f6b5faf77626ec1de9e48d86a6fc24f6f10591f Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 28 Nov 2017 17:52:30 +0100 Subject: [PATCH] Correct return LDAPerror_TypeError() LDAPerror_TypeError() returns (PyObject *)NULL. Some functions don't return a PyObject* so technically it's wrong to return (PyObject *)NULL. Return NULL instead. Signed-off-by: Christian Heimes --- Modules/LDAPObject.c | 9 ++++++--- Modules/ldapcontrol.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/LDAPObject.c b/Modules/LDAPObject.c index 4800724..cff9337 100644 --- a/Modules/LDAPObject.c +++ b/Modules/LDAPObject.c @@ -112,7 +112,8 @@ Tuple_to_LDAPMod( PyObject* tup, int no_op ) Py_ssize_t i, len, nstrs; if (!PyTuple_Check(tup)) { - return LDAPerror_TypeError("expected a tuple", tup); + LDAPerror_TypeError("expected a tuple", tup); + return NULL; } if (no_op) { @@ -209,13 +210,15 @@ List_to_LDAPMods( PyObject *list, int no_op ) { PyObject *item; if (!PySequence_Check(list)) { - return LDAPerror_TypeError("expected list of tuples", list); + LDAPerror_TypeError("expected list of tuples", list); + return NULL; } len = PySequence_Length(list); if (len < 0) { - return LDAPerror_TypeError("expected list of tuples", list); + LDAPerror_TypeError("expected list of tuples", list); + return NULL; } lms = PyMem_NEW(LDAPMod *, len + 1); diff --git a/Modules/ldapcontrol.c b/Modules/ldapcontrol.c index 3f5b2c4..b76d33c 100644 --- a/Modules/ldapcontrol.c +++ b/Modules/ldapcontrol.c @@ -71,7 +71,8 @@ Tuple_to_LDAPControl( PyObject* tup ) Py_ssize_t len; if (!PyTuple_Check(tup)) { - return LDAPerror_TypeError("expected a tuple", tup); + LDAPerror_TypeError("expected a tuple", tup); + return NULL; } if (!PyArg_ParseTuple( tup, "sbO", &oid, &iscritical, &bytes ))