Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd error handling to Python API calls in LDAPraise_for_message #341
Conversation
codecov
bot
commented
Jun 5, 2020
•
Codecov Report
@@ Coverage Diff @@
## master #341 +/- ##
==========================================
- Coverage 71.03% 68.29% -2.74%
==========================================
Files 49 49
Lines 4833 4861 +28
Branches 808 820 +12
==========================================
- Hits 3433 3320 -113
- Misses 1066 1187 +121
- Partials 334 354 +20
Continue to review full report at Codecov.
|
|
It'll review the PR next week or the week after. Too much C code for a Friday afternoon! |
| @@ -51,138 +51,193 @@ LDAPerr(int errnum) | |||
| PyObject * | |||
| LDAPraise_for_message(LDAP *l, LDAPMessage *m) | |||
| { | |||
| int myerrno, errnum, opt_errnum, res, msgid = -1, msgtype = 0; | |||
| PyObject *errobj = NULL; | |||
| PyObject *info; | |||
This comment has been minimized.
This comment has been minimized.
| PyErr_SetObject(errobj, info); | ||
| Py_DECREF(info); | ||
| ldap_memvfree((void **)refs); | ||
| PyErr_SetObject(errobj, info); |
This comment has been minimized.
This comment has been minimized.
droideck
Aug 5, 2020
Contributor
I get a segfault here:
test105_reconnect_restore (Tests.t_ldapobject.Test01_ReconnectLDAPObject) ... make: *** [Makefile:72: valgrind] Segmentation fault (core dumped)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
encukou commentedJun 5, 2020
Add CPython style error handling to
LDAPraise_for_message: ensure pointers are set to NULL when freed, and free all non-NULL pointers at the end. Usegototo jump to the cleanup. (The label is usually callederror, which here clashes with a variable name).Note that Python API sets the current exception on failure. If something else than C API fails,
PyErr_NoMemoryorPyErr_SetObjectis called before returning NULL.I recommend reviewing the diff with whitespace changes hidden (
-win Git CLI,?w=1in GitHub URLs).