Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Modules/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,18 @@ LDAPraise_for_message(LDAP *l, LDAPMessage *m)
}

if (errnum == LDAP_REFERRAL && refs != NULL && refs[0] != NULL) {
/* Return all referrals as a list in "reflist" */
PyObject *referralList = PyList_New(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check.

int i = 0;
while (refs[i] != NULL) {
PyObject *referralURL = Py_BuildValue("s", refs[i++]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PyUnicode_FromString() and check for error (NULL).

PyList_Append(referralList, referralURL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check.

Py_XDECREF(referralURL);
}
PyDict_SetItemString(info, "reflist", referralList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error check

Py_XDECREF(referralList);
/* Keep old behaviour, overshadow error message */
char err[1024];

snprintf(err, sizeof(err), "Referral:\n%s", refs[0]);
str = PyUnicode_FromString(err);
PyDict_SetItemString(info, "info", str);
Expand Down