Skip to content

Commit

Permalink
Correct return LDAPerror_TypeError()
Browse files Browse the repository at this point in the history
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 <cheimes@redhat.com>
  • Loading branch information
Christian Heimes committed Nov 29, 2017
1 parent ece4738 commit 7f6b5fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Modules/LDAPObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Modules/ldapcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ))
Expand Down

0 comments on commit 7f6b5fa

Please sign in to comment.